From: Noel Power Date: Fri, 23 Feb 2018 14:32:17 +0000 (+0000) Subject: samba python tests: convert 'except X, (tuple)' to 'except X as e' X-Git-Tag: talloc-2.1.12~409 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0de23d27d6b01f2501d076cc98f48ee72c48d50a;p=thirdparty%2Fsamba.git samba python tests: convert 'except X, (tuple)' to 'except X as e' In addition to converting the except line another line is also added for each except to extract the tuple contents. Signed-off-by: Noel Power Reviewed-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 8ed92814960..77758a4430a 100644 --- a/python/samba/tests/auth_log_pass_change.py +++ b/python/samba/tests/auth_log_pass_change.py @@ -290,7 +290,8 @@ class AuthLogPassChangeTests(samba.tests.auth_log_base.AuthLogTestBase): "userPassword: " + new_password + "\n" ) self.fail() - except LdbError, (num, msg): + except LdbError as e: + (num, msg) = e.args pass messages = self.waitForMessages(isLastExpectedMessage) @@ -320,7 +321,8 @@ class AuthLogPassChangeTests(samba.tests.auth_log_base.AuthLogTestBase): "userPassword: " + new_password + "\n" ) self.fail() - except LdbError, (num, msg): + except LdbError as e1: + (num, msg) = e1.args pass messages = self.waitForMessages(isLastExpectedMessage) diff --git a/python/samba/tests/dns.py b/python/samba/tests/dns.py index 1b5b64da3a4..8aecfe3be59 100644 --- a/python/samba/tests/dns.py +++ b/python/samba/tests/dns.py @@ -890,7 +890,8 @@ class TestZones(DNSTest): super(TestZones, self).tearDown() try: self.delete_zone(self.zone) - except RuntimeError, (num, string): + except RuntimeError as e: + (num, string) = e.args if num != werror.WERR_DNS_ERROR_ZONE_DOES_NOT_EXIST: raise diff --git a/python/samba/tests/samba_tool/fsmo.py b/python/samba/tests/samba_tool/fsmo.py index c985830cf6c..7fd0ae2e033 100644 --- a/python/samba/tests/samba_tool/fsmo.py +++ b/python/samba/tests/samba_tool/fsmo.py @@ -37,7 +37,8 @@ class FsmoCmdTestCase(SambaToolCmdTest): scope=ldb.SCOPE_BASE, attrs=["fsmoRoleOwner"]) self.assertTrue("DomainDnsZonesMasterRole owner: " + res[0]["fsmoRoleOwner"][0] in out) - except ldb.LdbError, (enum, string): + except ldb.LdbError as e: + (enum, string) = e.args if enum == ldb.ERR_NO_SUCH_OBJECT: self.assertTrue("The 'domaindns' role is not present in this domain" in out) else: diff --git a/python/samba/tests/samdb_api.py b/python/samba/tests/samdb_api.py index 81c62665dd4..259952031b5 100644 --- a/python/samba/tests/samdb_api.py +++ b/python/samba/tests/samdb_api.py @@ -56,7 +56,8 @@ class SamDBApiTestCase(TestCaseInTempDir): try: SamDB(url="tdb://" + existing_name) self.fail("Exception not thrown ") - except LdbError as (err, _): + except LdbError as e: + (err, _) = e.args self.assertEquals(err, ERR_OPERATIONS_ERROR) existing = open(existing_name, "r") @@ -136,7 +137,8 @@ class SamDBApiTestCase(TestCaseInTempDir): try: SamDB(url="tdb://" + self.tempdir + "/test.db") self.fail("Exception not thrown ") - except LdbError as (err, _): + except LdbError as e1: + (err, _) = e1.args self.assertEquals(err, ERR_OPERATIONS_ERROR) try: