Convert swigobject python test to be python 2 and 3 compatible

This commit is contained in:
William S Fulton 2020-08-14 23:27:35 +01:00
parent 982b08dced
commit 36bb54f01d
1 changed files with 13 additions and 4 deletions

View File

@ -1,5 +1,5 @@
from swigobject import *
import sys
a = A()
@ -11,7 +11,11 @@ if a1.this != a2.this:
raise RuntimeError
lthis = long(a.this)
if sys.version_info[0:2] < (3, 0):
lthis = long(a.this)
else:
lthis = int(a.this)
# match pointer value, but deal with leading zeros on 8/16 bit systems and
# different C++ compilers interpretation of %p
xstr1 = "%016X" % (lthis,)
@ -30,5 +34,10 @@ r = repr(a.this)
v1 = v_ptr(a)
v2 = v_ptr(a)
if long(v1) != long(v2):
raise RuntimeError
if sys.version_info[0:2] < (3, 0):
if long(v1) != long(v2):
raise RuntimeError
else:
if int(v1) != int(v2):
raise RuntimeError