Python 3 dropped exception handlers of the deprecated form:

  except Exception, e:

You must use the newer syntax of:

  except Exception as e:

This patch also enables a flake8 warning for this.

  H231 Python 3.x incompatible 'except x,y:' construct

Signed-off-by: Russell Bryant <russ...@ovn.org>
---
 Makefile.am                                         | 21 +++++++++++++--------
 debian/ovs-monitor-ipsec                            |  2 +-
 ofproto/ipfix-gen-entities                          |  2 +-
 tests/test-json.py                                  |  2 +-
 tests/test-ovsdb.py                                 |  6 +++---
 utilities/ovs-pcap.in                               |  4 ++--
 .../usr_share_openvswitch_scripts_ovs-xapi-sync     |  2 +-
 7 files changed, 22 insertions(+), 17 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index ef921ee..05edc03 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -343,17 +343,22 @@ endif
 if HAVE_FLAKE8
 ALL_LOCAL += flake8-check
 # http://flake8.readthedocs.org/en/latest/warnings.html
-# E123 closing bracket does not match indentation of opening bracket's line
-# E126 continuation line over-indented for hanging indent
-# E127 continuation line over-indented for visual indent
-# E128 continuation line under-indented for visual indent
-# E129 visually indented line with same indent as next logical line
-# E131 continuation line unaligned for hanging indent
-# W503 line break before binary operator
+# All warnings explicitly selected or ignored should be listed below.
+#
+# E***, W*** -- warnings from pep8
+#   E123 closing bracket does not match indentation of opening bracket's line
+#   E126 continuation line over-indented for hanging indent
+#   E127 continuation line over-indented for visual indent
+#   E128 continuation line under-indented for visual indent
+#   E129 visually indented line with same indent as next logical line
+#   E131 continuation line unaligned for hanging indent
+#   W503 line break before binary operator
+# F*** -- warnings native to flake8
 # D*** -- warnings from flake8-docstrings plugin
 # H*** -- warnings from flake8 hacking plugin (custom style checks beyond PEP8)
+#   H231 Python 3.x incompatible 'except x,y:' construct
 flake8-check: $(FLAKE8_PYFILES)
-       $(AM_V_GEN) if flake8 $^ 
--ignore=E123,E126,E127,E128,E129,E131,W503,D,H ${FLAKE8_FLAGS}; then touch $@; 
else exit 1; fi
+       $(AM_V_GEN) if flake8 $^ --select=H231 
--ignore=E123,E126,E127,E128,E129,E131,W503,D,H ${FLAKE8_FLAGS}; then touch $@; 
else exit 1; fi
 endif
 
 include $(srcdir)/manpages.mk
diff --git a/debian/ovs-monitor-ipsec b/debian/ovs-monitor-ipsec
index e79c755..efab91b 100755
--- a/debian/ovs-monitor-ipsec
+++ b/debian/ovs-monitor-ipsec
@@ -371,7 +371,7 @@ def update_ipsec(ipsec, interfaces, new_interfaces):
 
         try:
             ipsec.add_entry(vals["local_ip"], vals["remote_ip"], vals)
-        except error.Error, msg:
+        except error.Error as msg:
             vlog.warn("skipping ipsec config for %s: %s" % (name, msg))
 
 
diff --git a/ofproto/ipfix-gen-entities b/ofproto/ipfix-gen-entities
index 11d2aaf..54951b6 100755
--- a/ofproto/ipfix-gen-entities
+++ b/ofproto/ipfix-gen-entities
@@ -114,7 +114,7 @@ if __name__ == '__main__':
     try:
         options, args = getopt.gnu_getopt(sys.argv[1:], 'hV',
                                           ['help', 'version'])
-    except getopt.GetoptError, geo:
+    except getopt.GetoptError as geo:
         sys.stderr.write('%s: %s\n' % (sys.argv[0], geo.msg))
         sys.exit(1)
 
diff --git a/tests/test-json.py b/tests/test-json.py
index d9f0bfe..1356145 100644
--- a/tests/test-json.py
+++ b/tests/test-json.py
@@ -61,7 +61,7 @@ def main(argv):
 
     try:
         options, args = getopt.gnu_getopt(argv[1:], '', ['multiple'])
-    except getopt.GetoptError, geo:
+    except getopt.GetoptError as geo:
         sys.stderr.write("%s: %s\n" % (argv0, geo.msg))
         sys.exit(1)
 
diff --git a/tests/test-ovsdb.py b/tests/test-ovsdb.py
index e240208..5744fde 100644
--- a/tests/test-ovsdb.py
+++ b/tests/test-ovsdb.py
@@ -105,7 +105,7 @@ def do_parse_atoms(type_string, *atom_strings):
         try:
             atom = data.Atom.from_json(base, atom_json)
             print ovs.json.to_string(atom.to_json())
-        except error.Error, e:
+        except error.Error as e:
             print e.args[0].encode("utf8")
 
 
@@ -548,7 +548,7 @@ def main(argv):
         options, args = getopt.gnu_getopt(argv[1:], 't:h',
                                           ['timeout',
                                            'help'])
-    except getopt.GetoptError, geo:
+    except getopt.GetoptError as geo:
         sys.stderr.write("%s: %s\n" % (ovs.util.PROGRAM_NAME, geo.msg))
         sys.exit(1)
 
@@ -617,6 +617,6 @@ def main(argv):
 if __name__ == '__main__':
     try:
         main(sys.argv)
-    except error.Error, e:
+    except error.Error as e:
         sys.stderr.write("%s\n" % e)
         sys.exit(1)
diff --git a/utilities/ovs-pcap.in b/utilities/ovs-pcap.in
index 5253c31..ed35fc5 100755
--- a/utilities/ovs-pcap.in
+++ b/utilities/ovs-pcap.in
@@ -73,7 +73,7 @@ if __name__ == "__main__":
         try:
             options, args = getopt.gnu_getopt(sys.argv[1:], 'hV',
                                               ['help', 'version'])
-        except getopt.GetoptException, geo:
+        except getopt.GetoptException as geo:
             sys.stderr.write("%s: %s\n" % (argv0, geo.msg))
             sys.exit(1)
 
@@ -98,7 +98,7 @@ if __name__ == "__main__":
 
             print binascii.hexlify(packet)
 
-    except PcapException, e:
+    except PcapException as e:
         sys.stderr.write("%s: %s\n" % (argv0, e))
         sys.exit(1)
 
diff --git a/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync 
b/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync
index f6fbe85..bed8084 100755
--- a/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync
+++ b/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync
@@ -67,7 +67,7 @@ def init_session():
     try:
         session = XenAPI.xapi_local()
         session.xenapi.login_with_password("", "")
-    except XenAPI.Failure, e:
+    except XenAPI.Failure as e:
         session = None
         vlog.warn("Couldn't login to XAPI (%s)" % e)
         return False
-- 
2.5.0

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to