From 36bb54f01d0b5a0fef4c3843b366b5d78b8c04bb Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 14 Aug 2020 23:27:35 +0100 Subject: [PATCH] Convert swigobject python test to be python 2 and 3 compatible --- Examples/test-suite/python/swigobject_runme.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Examples/test-suite/python/swigobject_runme.py b/Examples/test-suite/python/swigobject_runme.py index 3b18a6b74..e28e187c9 100644 --- a/Examples/test-suite/python/swigobject_runme.py +++ b/Examples/test-suite/python/swigobject_runme.py @@ -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