samba python tests: convert 'except X, e' to 'except X as e'
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Tue, 13 Feb 2018 21:27:52 +0000 (10:27 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 14 Feb 2018 23:18:30 +0000 (00:18 +0100)
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/tests/auth_log_pass_change.py
python/samba/tests/dcerpc/array.py
python/samba/tests/dcerpc/testrpc.py
python/samba/tests/dns_forwarder.py
python/samba/tests/docs.py
python/samba/tests/netcmd.py
python/samba/tests/samba_tool/dnscmd.py
python/samba/tests/source.py

index a6850374547f3ae6e42b40272360f86512c7acc9..8ed92814960b0a1c3b4c2ca9cf58f1d6903817eb 100644 (file)
@@ -142,7 +142,7 @@ class AuthLogPassChangeTests(samba.tests.auth_log_base.AuthLogTestBase):
             net.change_password(newpassword=password.encode('utf-8'),
                                 oldpassword=USER_PASS,
                                 username=USER_NAME)
             net.change_password(newpassword=password.encode('utf-8'),
                                 oldpassword=USER_PASS,
                                 username=USER_NAME)
-        except Exception, msg:
+        except Exception as msg:
             exception_thrown = True
         self.assertEquals(True, exception_thrown,
                           "Expected exception not thrown")
             exception_thrown = True
         self.assertEquals(True, exception_thrown,
                           "Expected exception not thrown")
@@ -173,7 +173,7 @@ class AuthLogPassChangeTests(samba.tests.auth_log_base.AuthLogTestBase):
             net.change_password(newpassword=password.encode('utf-8'),
                                 oldpassword=USER_PASS,
                                 username="badUser")
             net.change_password(newpassword=password.encode('utf-8'),
                                 oldpassword=USER_PASS,
                                 username="badUser")
-        except Exception, msg:
+        except Exception as msg:
             exception_thrown = True
         self.assertEquals(True, exception_thrown,
                           "Expected exception not thrown")
             exception_thrown = True
         self.assertEquals(True, exception_thrown,
                           "Expected exception not thrown")
@@ -204,7 +204,7 @@ class AuthLogPassChangeTests(samba.tests.auth_log_base.AuthLogTestBase):
             net.change_password(newpassword=password.encode('utf-8'),
                                 oldpassword="badPassword",
                                 username=USER_NAME)
             net.change_password(newpassword=password.encode('utf-8'),
                                 oldpassword="badPassword",
                                 username=USER_NAME)
-        except Exception, msg:
+        except Exception as msg:
             exception_thrown = True
         self.assertEquals(True, exception_thrown,
                           "Expected exception not thrown")
             exception_thrown = True
         self.assertEquals(True, exception_thrown,
                           "Expected exception not thrown")
index da3b7a529b5cc86284be326ff9d20fd899ced083..fed03531afb91348dfc70cca5280d4a8fe4ee665 100644 (file)
@@ -195,11 +195,11 @@ class ArrayTests(samba.tests.TestCase):
         try:
             del rmd1.version
             self.fail("succeeded in deleting rmd1.version")
         try:
             del rmd1.version
             self.fail("succeeded in deleting rmd1.version")
-        except AttributeError, e:
+        except AttributeError as e:
             pass
 
         try:
             del rmd.ctr.array
             self.fail("succeeded in deleting rmd.ctr.array")
             pass
 
         try:
             del rmd.ctr.array
             self.fail("succeeded in deleting rmd.ctr.array")
-        except AttributeError, e:
+        except AttributeError as e:
             pass
             pass
index e35d6b55446c7a0e2673350dd6956981ac393ce6..fc3abf93395361783227724401ecc2c0eee11940 100644 (file)
@@ -45,7 +45,7 @@ class RpcTests(object):
                 continue
             try:
                 value = getattr(v, n)
                 continue
             try:
                 value = getattr(v, n)
-            except TypeError, errstr:
+            except TypeError as errstr:
                 if str(errstr) == "unknown union level":
                     print "ERROR: Unknown union level in %s.%s" % (typename, n)
                     self.errcount += 1
                 if str(errstr) == "unknown union level":
                     print "ERROR: Unknown union level in %s.%s" % (typename, n)
                     self.errcount += 1
@@ -68,7 +68,7 @@ class RpcTests(object):
             try:
                 print "Setting %s.%s" % (typename, n)
                 setattr(v, n, value)
             try:
                 print "Setting %s.%s" % (typename, n)
                 setattr(v, n, value)
-            except Exception, e:
+            except Exception as e:
                 if isinstance(e, AttributeError) and str(e).endswith("is read-only"):
                     # readonly, ignore
                     continue
                 if isinstance(e, AttributeError) and str(e).endswith("is read-only"):
                     # readonly, ignore
                     continue
@@ -82,7 +82,7 @@ class RpcTests(object):
                 if value != getattr(v, n):
                     print "ERROR: Comparison failed for %s.%s: %r != %r" % (typename, n, value, getattr(v, n))
                     continue
                 if value != getattr(v, n):
                     print "ERROR: Comparison failed for %s.%s: %r != %r" % (typename, n, value, getattr(v, n))
                     continue
-            except Exception, e:
+            except Exception as e:
                 print "ERROR: compare exception for %s.%s: %r: %s" % (typename, n, e.__class__, e)
                 continue
 
                 print "ERROR: compare exception for %s.%s: %r: %s" % (typename, n, e.__class__, e)
                 continue
 
@@ -104,7 +104,7 @@ class RpcTests(object):
                     initial_blocks = talloc.total_blocks(None)
                     self.check_type(interface, n, value)
                     self.check_blocks(None, initial_blocks)
                     initial_blocks = talloc.total_blocks(None)
                     self.check_type(interface, n, value)
                     self.check_blocks(None, initial_blocks)
-                except Exception, e:
+                except Exception as e:
                     print "ERROR: Failed to check_type %s.%s: %r: %s" % (iname, n, e.__class__, e)
                     self.errcount += 1
             elif callable(value):
                     print "ERROR: Failed to check_type %s.%s: %r: %s" % (iname, n, e.__class__, e)
                     self.errcount += 1
             elif callable(value):
index 51a86198b545ac5d12c25f97cc97357412ad02cc..cf9f537e461d82c1336a6cf857bd1d22e994bdb2 100644 (file)
@@ -190,7 +190,7 @@ class TestDnsForwarding(DNSTest):
             s.connect((host, port))
             try:
                 s.send('timeout 0', 0)
             s.connect((host, port))
             try:
                 s.send('timeout 0', 0)
-            except socket.error, e:
+            except socket.error as e:
                 if e.errno in (errno.ECONNREFUSED, errno.EHOSTUNREACH):
                     continue
 
                 if e.errno in (errno.ECONNREFUSED, errno.EHOSTUNREACH):
                     continue
 
index 1462600b3b1f88fa331a39303045beefe1b942b8..3d896d7c7d2bf87097ab3097e6aea1297a7c708d 100644 (file)
@@ -42,7 +42,7 @@ def get_documented_parameters(sourcedir):
         raise Exception("Unable to find parameters.all.xml")
     try:
         p = open(os.path.join(path, "parameters.all.xml"), 'r')
         raise Exception("Unable to find parameters.all.xml")
     try:
         p = open(os.path.join(path, "parameters.all.xml"), 'r')
-    except IOError, e:
+    except IOError as e:
         raise Exception("Error opening parameters file")
     out = p.read()
 
         raise Exception("Error opening parameters file")
     out = p.read()
 
@@ -65,7 +65,7 @@ def get_documented_tuples(sourcedir, omit_no_default=True):
         raise Exception("Unable to find parameters.all.xml")
     try:
         p = open(os.path.join(path, "parameters.all.xml"), 'r')
         raise Exception("Unable to find parameters.all.xml")
     try:
         p = open(os.path.join(path, "parameters.all.xml"), 'r')
-    except IOError, e:
+    except IOError as e:
         raise Exception("Error opening parameters file")
     out = p.read()
 
         raise Exception("Error opening parameters file")
     out = p.read()
 
index 2cbac4e8bff77b3450caf99409bba507da807c7a..54f05da35faa5bed674eb686eca3eea93899e72e 100644 (file)
@@ -29,7 +29,7 @@ class NetCmdTestCase(samba.tests.TestCase):
         cmd = cmd_klass(outf=StringIO(), errf=StringIO())
         try:
             retval = cmd._run(cmd_klass.__name__, *args)
         cmd = cmd_klass(outf=StringIO(), errf=StringIO())
         try:
             retval = cmd._run(cmd_klass.__name__, *args)
-        except Exception, e:
+        except Exception as e:
             cmd.show_command_error(e)
             retval = 1
         self.assertEquals(retcode, retval)
             cmd.show_command_error(e)
             retval = 1
         self.assertEquals(retcode, retval)
index bcd2c73981bfee42571abe127a6c658f8215d95b..c44a30837161df5ae8853493d73e839b80bf10ac 100644 (file)
@@ -189,7 +189,7 @@ class DnsCmdTestCase(SambaToolCmdTest):
             self.assertTrue("testrecord" in out and record_str in out,
                             "Query for a record which had DNS_RANK_NONE" \
                             "succeeded but produced no resulting records.")
             self.assertTrue("testrecord" in out and record_str in out,
                             "Query for a record which had DNS_RANK_NONE" \
                             "succeeded but produced no resulting records.")
-        except AssertionError, e:
+        except AssertionError as e:
             # Windows produces no resulting records
             pass
 
             # Windows produces no resulting records
             pass
 
@@ -200,7 +200,7 @@ class DnsCmdTestCase(SambaToolCmdTest):
         try:
             self.assertCmdFail(result, "Successfully added duplicate record" \
                                "of one which had DNS_RANK_NONE.")
         try:
             self.assertCmdFail(result, "Successfully added duplicate record" \
                                "of one which had DNS_RANK_NONE.")
-        except AssertionError, e:
+        except AssertionError as e:
             errors.append(e)
 
         # We should be able to delete it
             errors.append(e)
 
         # We should be able to delete it
@@ -210,7 +210,7 @@ class DnsCmdTestCase(SambaToolCmdTest):
         try:
             self.assertCmdSuccess(result, out, err, "Failed to delete record" \
                                   "which had DNS_RANK_NONE.")
         try:
             self.assertCmdSuccess(result, out, err, "Failed to delete record" \
                                   "which had DNS_RANK_NONE.")
-        except AssertionError, e:
+        except AssertionError as e:
             errors.append(e)
 
         # Now the record should not exist
             errors.append(e)
 
         # Now the record should not exist
@@ -220,7 +220,7 @@ class DnsCmdTestCase(SambaToolCmdTest):
         try:
             self.assertCmdFail(result, "Successfully queried for deleted record" \
                                "which had DNS_RANK_NONE.")
         try:
             self.assertCmdFail(result, "Successfully queried for deleted record" \
                                "which had DNS_RANK_NONE.")
-        except AssertionError, e:
+        except AssertionError as e:
             errors.append(e)
 
         if len(errors) > 0:
             errors.append(e)
 
         if len(errors) > 0:
index 22ef3e60b9053376a6f216dea05202d4ecff6a78..2a8e675f5156c49c374262ae676615c0e381e5ea 100644 (file)
@@ -61,7 +61,7 @@ def get_source_file_contents():
     for fname in get_python_source_files():
         try:
             f = open(fname, 'rb')
     for fname in get_python_source_files():
         try:
             f = open(fname, 'rb')
-        except IOError, e:
+        except IOError as e:
             if e.errno == errno.ENOENT:
                 warnings.warn("source file %s broken link?" % fname)
                 continue
             if e.errno == errno.ENOENT:
                 warnings.warn("source file %s broken link?" % fname)
                 continue