diff options
author | Scott Garman <scott.a.garman@intel.com> | 2011-06-14 16:44:58 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-06-15 11:08:43 +0100 |
commit | dbf5f42b06bef81749b13aa99945cc1292a6676d (patch) | |
tree | 04b6a3bdb3b4dfcae58ad0e233eb700317736984 /lib/bb/pysh | |
parent | 9bff182a4ba9571679985b45b309990a6eddad14 (diff) | |
download | bitbake-contrib-dbf5f42b06bef81749b13aa99945cc1292a6676d.tar.gz |
make exception handling syntax consistent
Update exception handling syntax to use the modern style:
except ExcType as localvar
Signed-off-by: Scott Garman <scott.a.garman@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/pysh')
-rw-r--r-- | lib/bb/pysh/builtin.py | 10 | ||||
-rw-r--r-- | lib/bb/pysh/interp.py | 14 |
2 files changed, 12 insertions, 12 deletions
diff --git a/lib/bb/pysh/builtin.py b/lib/bb/pysh/builtin.py index 25ad22eb7..b748e4a4f 100644 --- a/lib/bb/pysh/builtin.py +++ b/lib/bb/pysh/builtin.py @@ -151,7 +151,7 @@ def builtin_trap(name, args, interp, env, stdin, stdout, stderr, debugflags): for sig in args[1:]: try: env.traps[sig] = action - except Exception, e: + except Exception as e: stderr.write('trap: %s\n' % str(e)) return 0 @@ -214,7 +214,7 @@ def utility_cat(name, args, interp, env, stdin, stdout, stderr, debugflags): data = f.read() finally: f.close() - except IOError, e: + except IOError as e: if e.errno != errno.ENOENT: raise status = 1 @@ -433,7 +433,7 @@ def utility_mkdir(name, args, interp, env, stdin, stdout, stderr, debugflags): if option.has_p: try: os.makedirs(path) - except IOError, e: + except IOError as e: if e.errno != errno.EEXIST: raise else: @@ -561,7 +561,7 @@ def utility_sort(name, args, interp, env, stdin, stdout, stderr, debugflags): lines = f.readlines() finally: f.close() - except IOError, e: + except IOError as e: stderr.write(str(e) + '\n') return 1 @@ -679,7 +679,7 @@ def run_command(name, args, interp, env, stdin, stdout, p = subprocess.Popen([name] + args, cwd=env['PWD'], env=exec_env, stdin=stdin, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) out, err = p.communicate() - except WindowsError, e: + except WindowsError as e: raise UtilityError(str(e)) if not unixoutput: diff --git a/lib/bb/pysh/interp.py b/lib/bb/pysh/interp.py index efe5181e1..25d8c92ec 100644 --- a/lib/bb/pysh/interp.py +++ b/lib/bb/pysh/interp.py @@ -248,7 +248,7 @@ class Redirections: raise NotImplementedError('cannot open absolute path %s' % repr(filename)) else: f = file(filename, mode+'b') - except IOError, e: + except IOError as e: raise RedirectionError(str(e)) wrapper = None @@ -368,7 +368,7 @@ def resolve_shebang(path, ignoreshell=False): if arg is None: return [cmd, win32_to_unix_path(path)] return [cmd, arg, win32_to_unix_path(path)] - except IOError, e: + except IOError as e: if e.errno!=errno.ENOENT and \ (e.errno!=errno.EPERM and not os.path.isdir(path)): # Opening a directory raises EPERM raise @@ -747,7 +747,7 @@ class Interpreter: for cmd in cmds: try: status = self.execute(cmd) - except ExitSignal, e: + except ExitSignal as e: if sourced: raise status = int(e.args[0]) @@ -758,13 +758,13 @@ class Interpreter: if 'debug-utility' in self._debugflags or 'debug-cmd' in self._debugflags: self.log('returncode ' + str(status)+ '\n') return status - except CommandNotFound, e: + except CommandNotFound as e: print >>self._redirs.stderr, str(e) self._redirs.stderr.flush() # Command not found by non-interactive shell # return 127 raise - except RedirectionError, e: + except RedirectionError as e: # TODO: should be handled depending on the utility status print >>self._redirs.stderr, str(e) self._redirs.stderr.flush() @@ -948,7 +948,7 @@ class Interpreter: status = self.execute(func, redirs) finally: redirs.close() - except ReturnSignal, e: + except ReturnSignal as e: status = int(e.args[0]) env['?'] = status return status @@ -1044,7 +1044,7 @@ class Interpreter: except ReturnSignal: raise - except ShellError, e: + except ShellError as e: if is_special or isinstance(e, (ExitSignal, ShellSyntaxError, ExpansionError)): raise e |