Use Python 2.6 "except E as ..." syntax
PATCH 3/4 Revert "tracetool: use Python 2.4-compatible exception handling syntax"
In reply to Markus ArmbrusterThis reverts commit 662da3854e3f490223373b40afdcfcc339d14aa5.
--- scripts/tracetool.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/tracetool.py +2 -2
@@ -71,7 +71,7 @@ def main(args): try: opts, args = getopt.getopt(args[1:], "", long_opts) - except getopt.GetoptError, err: + except getopt.GetoptError as err: error_opt(str(err)) check_backends = False
@@ -132,7 +132,7 @@ def main(args): try: tracetool.generate(sys.stdin, arg_format, arg_backends, binary=binary, probe_prefix=probe_prefix) - except tracetool.TracetoolError, e: + except tracetool.TracetoolError as e: error_opt(str(e)) if __name__ == "__main__":
Signature · 1 line
2.4.3
PATCH 2/4 scripts/qmp: Use Python 2.6 "except E as ..." syntax
In reply to Markus ArmbrusterPEP 8 calls for it, because it's forward compatibile with Python 3.
--- scripts/qmp/qemu-ga-client | 2 +- scripts/qmp/qmp | 4 ++-- scripts/qmp/qmp-shell | 2 +- scripts/qmp/qmp.py | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-)
scripts/qmp/qemu-ga-client +1 -1
@@ -259,7 +259,7 @@ def main(address, cmd, args): try: client = QemuGuestAgentClient(address) - except QemuGuestAgent.error, e: + except QemuGuestAgent.error as e: import errno print(e)
scripts/qmp/qmp +2 -2
@@ -91,8 +91,8 @@ def main(args): try: os.environ['QMP_PATH'] = path os.execvp(fullcmd, [fullcmd] + args) - except OSError, (errno, msg): - if errno == 2: + except OSError as exc: + if exc.errno == 2: print 'Command "%s" not found.' % (fullcmd) return 1 raise
scripts/qmp/qmp-shell +1 -1
@@ -240,7 +240,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): def _execute_cmd(self, cmdline): try: qmpcmd = self.__build_cmd(cmdline) - except Exception, e: + except Exception as e: print 'Error while parsing command line: %s' % e print 'command format: <command-name> ', print '[arg-name1=arg1] ... [arg-nameN=argN]'
scripts/qmp/qmp.py +2 -2
@@ -92,7 +92,7 @@ class QEMUMonitorProtocol: self.__sock.setblocking(0) try: self.__json_read() - except socket.error, err: + except socket.error as err: if err[0] == errno.EAGAIN: # No data available pass
@@ -150,7 +150,7 @@ class QEMUMonitorProtocol: """ try: self.__sock.sendall(json.dumps(qmp_cmd)) - except socket.error, err: + except socket.error as err: if err[0] == errno.EPIPE: return raise socket.error(err)
Signature · 1 line
2.4.3
PATCH 1/4 qapi: Use Python 2.6 "except E as ..." syntax
In reply to Markus ArmbrusterPEP 8 calls for it, because it's forward compatibile with Python 3.
--- scripts/qapi.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
scripts/qapi.py +4 -4
@@ -152,7 +152,7 @@ class QAPISchemaParser(object): continue try: fobj = open(incl_abs_fname, 'r') - except IOError, e: + except IOError as e: raise QAPIExprError(expr_info, '%s: %s' % (e.strerror, include)) exprs_include = QAPISchemaParser(fobj, previously_included,
@@ -1148,7 +1148,7 @@ class QAPISchema(object): self._predefining = False self._def_exprs() self.check() - except (QAPISchemaError, QAPIExprError), err: + except (QAPISchemaError, QAPIExprError) as err: print >>sys.stderr, err exit(1)
@@ -1639,7 +1639,7 @@ def parse_command_line(extra_options="", extra_long_options=[]): "chp:o:" + extra_options, ["source", "header", "prefix=", "output-dir="] + extra_long_options) - except getopt.GetoptError, err: + except getopt.GetoptError as err: print >>sys.stderr, "%s: %s" % (sys.argv[0], str(err)) sys.exit(1)
@@ -1693,7 +1693,7 @@ def open_output(output_dir, do_c, do_h, prefix, c_file, h_file, if output_dir: try: os.makedirs(output_dir) - except os.error, e: + except os.error as e: if e.errno != errno.EEXIST: raise
Signature · 1 line
2.4.3
PATCH 4/4 tests: Use Python 2.6 "except E as ..." syntax
In reply to Markus ArmbrusterPEP 8 calls for it, because it's forward compatibile with Python 3.
--- tests/image-fuzzer/runner.py | 12 ++++++------ tests/qemu-iotests/qed.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-)
tests/image-fuzzer/runner.py +6 -6
@@ -157,7 +157,7 @@ class TestEnv(object): try: os.makedirs(self.current_dir) - except OSError, e: + except OSError as e: print >>sys.stderr, \ "Error: The working directory '%s' cannot be used. Reason: %s"\ % (self.work_dir, e[1])
@@ -244,7 +244,7 @@ class TestEnv(object): temp_log = StringIO.StringIO() try: retcode = run_app(temp_log, current_cmd) - except OSError, e: + except OSError as e: multilog("%sError: Start of '%s' failed. Reason: %s\n\n" % (test_summary, os.path.basename(current_cmd[0]), e[1]),
@@ -356,7 +356,7 @@ if __name__ == '__main__': opts, args = getopt.gnu_getopt(sys.argv[1:], 'c:hs:kvd:', ['command=', 'help', 'seed=', 'config=', 'keep_passed', 'verbose', 'duration=']) - except getopt.error, e: + except getopt.error as e: print >>sys.stderr, \ "Error: %s\n\nTry 'runner.py --help' for more information" % e sys.exit(1)
@@ -374,7 +374,7 @@ if __name__ == '__main__': elif opt in ('-c', '--command'): try: command = json.loads(arg) - except (TypeError, ValueError, NameError), e: + except (TypeError, ValueError, NameError) as e: print >>sys.stderr, \ "Error: JSON array of test commands cannot be loaded.\n" \ "Reason: %s" % e
@@ -390,7 +390,7 @@ if __name__ == '__main__': elif opt == '--config': try: config = json.loads(arg) - except (TypeError, ValueError, NameError), e: + except (TypeError, ValueError, NameError) as e: print >>sys.stderr, \ "Error: JSON array with the fuzzer configuration cannot" \ " be loaded\nReason: %s" % e
@@ -414,7 +414,7 @@ if __name__ == '__main__': try: image_generator = __import__(generator_name) - except ImportError, e: + except ImportError as e: print >>sys.stderr, \ "Error: The image generator '%s' cannot be imported.\n" \ "Reason: %s" % (generator_name, e)
tests/qemu-iotests/qed.py +1 -1
@@ -227,7 +227,7 @@ def main(): qed = QED(open(filename, 'r+b')) try: globals()[cmd](qed, *sys.argv[3:]) - except TypeError, e: + except TypeError as e: sys.stderr.write(globals()[cmd].__doc__ + '\n') sys.exit(1)
Signature · 1 line
2.4.3
cover Use Python 2.6 "except E as ..." syntax
I can take this through my tree, but of course don't mind if a maintainer prefers to pick up "his" parts.
Markus Armbruster (4):
qapi: Use Python 2.6 "except E as ..." syntax scripts/qmp: Use Python 2.6 "except E as ..." syntax Revert "tracetool: use Python 2.4-compatible exception handling
syntax"
tests: Use Python 2.6 "except E as ..." syntax
scripts/qapi.py | 8 ++++---- scripts/qmp/qemu-ga-client | 2 +- scripts/qmp/qmp | 4 ++-- scripts/qmp/qmp-shell | 2 +- scripts/qmp/qmp.py | 4 ++-- scripts/tracetool.py | 4 ++-- tests/image-fuzzer/runner.py | 12 ++++++------ tests/qemu-iotests/qed.py | 2 +- 8 files changed, 19 insertions(+), 19 deletions(-)
Signature · 1 line
2.4.3
Re: [Qemu-devel] [PATCH 1/4] qapi: Use Python 2.6 "except E as ..." syntax
In reply to Markus ArmbrusterQuoted 1 line · Markus Armbruster
PEP 8 calls for it, because it's forward compatibile with Python 3.
And possible as a cleanup only because we require 2.6 as a minimum since fec21036 (your subject line hints at it, even if not stating it outright).
Quoted 5 lines
Signed-off-by Markus Armbruster <[email protected]>--- scripts/qapi.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH 2/4] scripts/qmp: Use Python 2.6 "except E as ..." syntax
In reply to Markus ArmbrusterQuoted 1 line · Markus Armbruster
PEP 8 calls for it, because it's forward compatibile with Python 3.
Here, and also in 1/4,
s/compatibile/compatible/
Quoted 8 lines
Signed-off-by Markus Armbruster <[email protected]>--- scripts/qmp/qemu-ga-client | 2 +- scripts/qmp/qmp | 4 ++-- scripts/qmp/qmp-shell | 2 +- scripts/qmp/qmp.py | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH 3/4] Revert "tracetool: use Python 2.4-compatible exception handling syntax"
In reply to Markus ArmbrusterQuoted 6 lines · Markus Armbruster
This reverts commit
662da3854e3f490223373b40afdcfcc339d14aa5.Signed-off-by Markus Armbruster <[email protected]>--- scripts/tracetool.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Might be nice to mention fec21036 as the reason why we can revert.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH 4/4] tests: Use Python 2.6 "except E as ..." syntax
In reply to Markus ArmbrusterQuoted 1 line · Markus Armbruster
PEP 8 calls for it, because it's forward compatibile with Python 3.
Another s/compatibile/compatible/
Quoted 6 lines
Signed-off-by Markus Armbruster <[email protected]>--- tests/image-fuzzer/runner.py | 12 ++++++------ tests/qemu-iotests/qed.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH 1/4] qapi: Use Python 2.6 "except E as ..." syntax
In reply to Eric BlakeQuoted 5 lines · Eric Blake
Quoted 1 line · Markus Armbruster
PEP 8 calls for it, because it's forward compatibile with Python 3.
And possible as a cleanup only because we require 2.6 as a minimum since
fec21036(your subject line hints at it, even if not stating it outright).
What about:
Supported since Python 2.6, which we require (commit fec2103).
Quoted 7 lines
Quoted 5 lines
Signed-off-by Markus Armbruster <[email protected]>--- scripts/qapi.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)Reviewed-by Eric Blake <[email protected]>
Thanks!
Re: [Qemu-devel] [PATCH 3/4] Revert "tracetool: use Python 2.4-compatible exception handling syntax"
In reply to Eric BlakeQuoted 9 lines · Eric Blake
Quoted 6 lines · Markus Armbruster
This reverts commit
662da3854e3f490223373b40afdcfcc339d14aa5.Signed-off-by Markus Armbruster <[email protected]>--- scripts/tracetool.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Might be nice to mention
fec21036as the reason why we can revert.
What about:
We require Python 2.6 now (commit fec2103).
Quoted 1 line
Reviewed-by Eric Blake <[email protected]>
Thanks!
Re: [Qemu-devel] [PATCH 1/4] qapi: Use Python 2.6 "except E as ..." syntax
In reply to Markus ArmbrusterQuoted 11 lines · Markus Armbruster
Quoted 5 lines · Eric Blake
Quoted 1 line · Markus Armbruster
PEP 8 calls for it, because it's forward compatibile with Python 3.
And possible as a cleanup only because we require 2.6 as a minimum since
fec21036(your subject line hints at it, even if not stating it outright).What about:
Supported since Python 2.6, which we require (commit fec2103).
Sounds good. Looks like you can pretty much copy/paste that into 1, 2, and 4.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH 3/4] Revert "tracetool: use Python 2.4-compatible exception handling syntax"
In reply to Markus ArmbrusterQuoted 10 lines · Markus Armbruster
Quoted 8 lines · Eric Blake
Quoted 6 lines · Markus Armbruster
This reverts commit
662da3854e3f490223373b40afdcfcc339d14aa5.Signed-off-by Markus Armbruster <[email protected]>--- scripts/tracetool.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 5 lines
Quoted 1 line
Might be nice to mention
fec21036as the reason why we can revert.What about:
We require Python 2.6 now (commit fec2103).
Yes, that makes this commit a lot more meaningful.
Quoted 5 lines
Quoted 2 lines
Reviewed-by Eric Blake <[email protected]>Thanks!
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH 1/4] qapi: Use Python 2.6 "except E as ..." syntax
In reply to Markus ArmbrusterQuoted 1 line · Markus Armbruster
PEP 8 calls for it, because it's forward compatibile with Python 3.
Typo nit: "compatible".
thanks
-- PMM
Quoted 10 lines · Markus Armbruster
I can take this through my tree, but of course don't mind if a maintainer prefers to pick up "his" parts.
Markus Armbruster (4):
qapi: Use Python 2.6 "except E as ..." syntaxscripts/qmp: Use Python 2.6 "except E as ..." syntax Revert "tracetool: use Python 2.4-compatible exception handling
syntax"
tests: Use Python 2.6 "except E as ..." syntax
Quoted 13 lines
scripts/qapi.py | 8 ++++---- scripts/qmp/qemu-ga-client | 2 +- scripts/qmp/qmp | 4 ++-- scripts/qmp/qmp-shell | 2 +- scripts/qmp/qmp.py | 4 ++-- scripts/tracetool.py | 4 ++-- tests/image-fuzzer/runner.py | 12 ++++++------ tests/qemu-iotests/qed.py | 2 +- 8 files changed, 19 insertions(+), 19 deletions(-)Signature · 1 line
2.4.3