From 32d5addaa68ca25fdf7265ac5fa96faa89673ed3 Mon Sep 17 00:00:00 2001 From: Marcelo Matus Date: Wed, 2 Mar 2005 17:52:34 +0000 Subject: [PATCH] fix hex pointer conversion git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7021 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/python/swigobject.i | 2 +- Examples/test-suite/python/swigobject_runme.py | 4 +++- Lib/python/pyrun.swg | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/python/swigobject.i b/Examples/test-suite/python/swigobject.i index 760b64025..cd802cf38 100644 --- a/Examples/test-suite/python/swigobject.i +++ b/Examples/test-suite/python/swigobject.i @@ -10,7 +10,7 @@ const char* pointer_str(A *a){ static char result[1024]; - sprintf(result,"%x",a); + sprintf(result,"%p",a); return result; } diff --git a/Examples/test-suite/python/swigobject_runme.py b/Examples/test-suite/python/swigobject_runme.py index c8fda5c21..7c2992dff 100644 --- a/Examples/test-suite/python/swigobject_runme.py +++ b/Examples/test-suite/python/swigobject_runme.py @@ -11,10 +11,12 @@ if a1.this != a2.this: lthis = long(a.this) -xstr1 = "%x" % (lthis,) +xstr1 = "0x%x" % (lthis,) xstr2 = pointer_str(a) +print hex(lthis) if xstr1 != xstr2: + print xstr1, xstr2 raise RuntimeError s = str(a.this) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index be910835b..ffb9043e3 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -120,7 +120,7 @@ SWIGRUNTIME PyObject * PySwigObject_hex(PySwigObject *v) { char buf[100]; - PyOS_snprintf(buf, sizeof(buf), "0x%lx", (unsigned long)v->ptr); + PyOS_snprintf(buf, sizeof(buf), "%p", v->ptr); return PyString_FromString(buf); }