diff mbox

[1/4] qapi: Use Python 2.6 "except E as ..." syntax

Message ID 1450346791-25562-2-git-send-email-armbru@redhat.com
State New
Headers show

Commit Message

Markus Armbruster Dec. 17, 2015, 10:06 a.m. UTC
PEP 8 calls for it, because it's forward compatibile with Python 3.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 scripts/qapi.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Eric Blake Dec. 17, 2015, 5:26 p.m. UTC | #1
On 12/17/2015 03:06 AM, Markus Armbruster wrote:
> 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).

> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  scripts/qapi.py | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

Reviewed-by: Eric Blake <eblake@redhat.com>
Markus Armbruster Dec. 17, 2015, 6:35 p.m. UTC | #2
Eric Blake <eblake@redhat.com> writes:

> On 12/17/2015 03:06 AM, Markus Armbruster wrote:
>> 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).

>> 
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> ---
>>  scripts/qapi.py | 8 ++++----
>>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> Reviewed-by: Eric Blake <eblake@redhat.com>

Thanks!
Eric Blake Dec. 17, 2015, 7:58 p.m. UTC | #3
On 12/17/2015 11:35 AM, Markus Armbruster wrote:
> Eric Blake <eblake@redhat.com> writes:
> 
>> On 12/17/2015 03:06 AM, Markus Armbruster wrote:
>>> 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.
Peter Maydell Dec. 17, 2015, 8 p.m. UTC | #4
On 17 December 2015 at 10:06, Markus Armbruster <armbru@redhat.com> wrote:
> PEP 8 calls for it, because it's forward compatibile with Python 3.

Typo nit: "compatible".

thanks
-- PMM
diff mbox

Patch

diff --git a/scripts/qapi.py b/scripts/qapi.py
index 7c50cc4..ba7151b 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -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