diff options
author | William S Fulton <wsf@fultondesigns.co.uk> | 2020-08-14 23:27:35 +0100 |
---|---|---|
committer | William S Fulton <wsf@fultondesigns.co.uk> | 2020-08-14 23:27:35 +0100 |
commit | 36bb54f01d0b5a0fef4c3843b366b5d78b8c04bb (patch) | |
tree | d7a176ff2348c397c77406c050ef128e00adac43 | |
parent | 982b08dcedc4002c8cf4a5b1d19dfb930e6fa6b1 (diff) | |
download | swig-36bb54f01d0b5a0fef4c3843b366b5d78b8c04bb.tar.gz |
Convert swigobject python test to be python 2 and 3 compatible
-rw-r--r-- | Examples/test-suite/python/swigobject_runme.py | 17 |
1 files 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 |