From: Douglas Bagnall Date: Tue, 13 Feb 2018 21:27:52 +0000 (+1300) Subject: samba python tests: convert 'except X, e' to 'except X as e' X-Git-Tag: tevent-0.9.36~86 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=28134d002b632a7fcd52906604412889fc973ef5;p=thirdparty%2Fsamba.git samba python tests: convert 'except X, e' to 'except X as e' Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett --- diff --git a/python/samba/tests/auth_log_pass_change.py b/python/samba/tests/auth_log_pass_change.py index a6850374547..8ed92814960 100644 --- a/python/samba/tests/auth_log_pass_change.py +++ b/python/samba/tests/auth_log_pass_change.py @@ -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) - except Exception, msg: + except Exception as msg: 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") - except Exception, msg: + except Exception as msg: 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) - except Exception, msg: + except Exception as msg: exception_thrown = True self.assertEquals(True, exception_thrown, "Expected exception not thrown") diff --git a/python/samba/tests/dcerpc/array.py b/python/samba/tests/dcerpc/array.py index da3b7a529b5..fed03531afb 100644 --- a/python/samba/tests/dcerpc/array.py +++ b/python/samba/tests/dcerpc/array.py @@ -195,11 +195,11 @@ class ArrayTests(samba.tests.TestCase): 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") - except AttributeError, e: + except AttributeError as e: pass diff --git a/python/samba/tests/dcerpc/testrpc.py b/python/samba/tests/dcerpc/testrpc.py index e35d6b55446..fc3abf93395 100644 --- a/python/samba/tests/dcerpc/testrpc.py +++ b/python/samba/tests/dcerpc/testrpc.py @@ -45,7 +45,7 @@ class RpcTests(object): 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 @@ -68,7 +68,7 @@ class RpcTests(object): 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 @@ -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 - except Exception, e: + except Exception as e: 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) - 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): diff --git a/python/samba/tests/dns_forwarder.py b/python/samba/tests/dns_forwarder.py index 51a86198b54..cf9f537e461 100644 --- a/python/samba/tests/dns_forwarder.py +++ b/python/samba/tests/dns_forwarder.py @@ -190,7 +190,7 @@ class TestDnsForwarding(DNSTest): 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 diff --git a/python/samba/tests/docs.py b/python/samba/tests/docs.py index 1462600b3b1..3d896d7c7d2 100644 --- a/python/samba/tests/docs.py +++ b/python/samba/tests/docs.py @@ -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') - except IOError, e: + except IOError as e: 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') - except IOError, e: + except IOError as e: raise Exception("Error opening parameters file") out = p.read() diff --git a/python/samba/tests/netcmd.py b/python/samba/tests/netcmd.py index 2cbac4e8bff..54f05da35fa 100644 --- a/python/samba/tests/netcmd.py +++ b/python/samba/tests/netcmd.py @@ -29,7 +29,7 @@ class NetCmdTestCase(samba.tests.TestCase): 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) diff --git a/python/samba/tests/samba_tool/dnscmd.py b/python/samba/tests/samba_tool/dnscmd.py index bcd2c73981b..c44a3083716 100644 --- a/python/samba/tests/samba_tool/dnscmd.py +++ b/python/samba/tests/samba_tool/dnscmd.py @@ -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.") - except AssertionError, e: + except AssertionError as e: # 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.") - except AssertionError, e: + except AssertionError as e: 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.") - except AssertionError, e: + except AssertionError as e: 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.") - except AssertionError, e: + except AssertionError as e: errors.append(e) if len(errors) > 0: diff --git a/python/samba/tests/source.py b/python/samba/tests/source.py index 22ef3e60b90..2a8e675f515 100644 --- a/python/samba/tests/source.py +++ b/python/samba/tests/source.py @@ -61,7 +61,7 @@ def get_source_file_contents(): 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