From 62d538fbe65cf61ebc5996b0d6eb7e4ec47b6ead Mon Sep 17 00:00:00 2001 From: Scott Garman Date: Tue, 14 Jun 2011 16:44:58 -0700 Subject: make exception handling syntax consistent Update exception handling syntax to use the modern style: except ExcType as localvar (Bitbake rev: dbf5f42b06bef81749b13aa99945cc1292a6676d) Signed-off-by: Scott Garman Signed-off-by: Richard Purdie --- bitbake/lib/bb/pysh/builtin.py | 10 +++++----- bitbake/lib/bb/pysh/interp.py | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'bitbake/lib/bb/pysh') diff --git a/bitbake/lib/bb/pysh/builtin.py b/bitbake/lib/bb/pysh/builtin.py index 25ad22eb74..b748e4a4f2 100644 --- a/bitbake/lib/bb/pysh/builtin.py +++ b/bitbake/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/bitbake/lib/bb/pysh/interp.py b/bitbake/lib/bb/pysh/interp.py index efe5181e1e..25d8c92ec4 100644 --- a/bitbake/lib/bb/pysh/interp.py +++ b/bitbake/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 -- cgit v1.2.3-54-g00ecf