python/samba: Py2|Py3 compat, fix more missed exception tuple issues
authorNoel Power <noel.power@suse.com>
Mon, 28 May 2018 15:22:25 +0000 (16:22 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 19 Jun 2018 22:18:20 +0000 (00:18 +0200)
python/samba/drs_utils.py
python/samba/emulate/traffic_packets.py
python/samba/tests/net_join_no_spnego.py
python/samba/tests/py_credentials.py

index 7fab4802522fefb2a865a85b52d24f2558a403a3..aa4605e0767cd6a0063ba79b5d78873d3ea789da 100644 (file)
@@ -319,7 +319,7 @@ class drs_Replicate(object):
                     schema=schema, req_level=req_level, req=req)
             except WERRORError as e:
                 # Check if retrying with the GET_TGT flag set might resolve this error
-                if self._should_retry_with_get_tgt(e[0], req):
+                if self._should_retry_with_get_tgt(e.args[0], req):
 
                     print("Missing target object - retrying with DRS_GET_TGT")
                     req.more_flags |= drsuapi.DRSUAPI_DRS_GET_TGT
index 3f5db4317a36b239e7eaf7e0c407d4a6d6f83468..bc52de06ff0673065b8d3f079ae85a22aa0d7196 100644 (file)
@@ -47,7 +47,7 @@ def check_runtime_error(runtime, val):
     if runtime is None:
         return False
 
-    err32 = uint32(runtime[0])
+    err32 = uint32(runtime.args[0])
     if err32 == val:
         return True
 
index 09a2856c9b5b51758547c47028f2811dc097adc8..85c6f888d4414b6ccf52818cd4238324c7c907a3 100644 (file)
@@ -55,7 +55,7 @@ class NetJoinNoSpnegoTests(samba.tests.TestCaseInTempDir):
                 self.domain, netbios_name, LIBNET_JOIN_AUTOMATIC,
                 machinepass=machinepass)
         except NTSTATUSError as e:
-            code = ctypes.c_uint32(e[0]).value
+            code = ctypes.c_uint32(e.args[0]).value
             if code == ntstatus.NT_STATUS_CONNECTION_DISCONNECTED:
                 self.fail("Connection failure")
             elif code == ntstatus.NT_STATUS_ACCESS_DENIED:
@@ -82,7 +82,7 @@ class NetJoinNoSpnegoTests(samba.tests.TestCaseInTempDir):
                 self.domain, netbios_name, LIBNET_JOIN_AUTOMATIC,
                 machinepass=machinepass)
         except NTSTATUSError as e:
-            code = ctypes.c_uint32(e[0]).value
+            code = ctypes.c_uint32(e.args[0]).value
             if code == ntstatus.NT_STATUS_CONNECTION_DISCONNECTED:
                 self.fail("Connection failure")
             raise
index 2f5a7d61a12b319282e38df9c843a96b0eb6edd4..c29afd1cf704c93230426a8716c05fa8d5b62483 100644 (file)
@@ -123,7 +123,7 @@ class PyCredentialsTests(TestCase):
                                    validation_level,
                                    netr_flags)
         except NTSTATUSError as e:
-            enum = ctypes.c_uint32(e[0]).value
+            enum = ctypes.c_uint32(e.args[0]).value
             if enum == ntstatus.NT_STATUS_WRONG_PASSWORD:
                 self.fail("got wrong password error")
             else:
@@ -150,7 +150,7 @@ class PyCredentialsTests(TestCase):
                                    validation_level,
                                    netr_flags)
         except NTSTATUSError as e:
-            enum = ctypes.c_uint32(e[0]).value
+            enum = ctypes.c_uint32(e.args[0]).value
             if enum == ntstatus.NT_STATUS_WRONG_PASSWORD:
                 self.fail("got wrong password error")
             else:
@@ -176,7 +176,7 @@ class PyCredentialsTests(TestCase):
                                    validation_level,
                                    netr_flags)
         except NTSTATUSError as e:
-            enum = ctypes.c_uint32(e[0]).value
+            enum = ctypes.c_uint32(e.args[0]).value
             if enum == ntstatus.NT_STATUS_WRONG_PASSWORD:
                 self.fail("got wrong password error")
             else:
@@ -204,7 +204,7 @@ class PyCredentialsTests(TestCase):
                                    validation_level,
                                    netr_flags)
         except NTSTATUSError as e:
-            enum = ctypes.c_uint32(e[0]).value
+            enum = ctypes.c_uint32(e.args[0]).value
             if enum == ntstatus.NT_STATUS_WRONG_PASSWORD:
                 self.fail("got wrong password error")
             else: