Fixes to support Python 3.0.1 and higher.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11143 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
fcf2d3ddb8
commit
caa6f2b9fa
4 changed files with 32 additions and 17 deletions
|
|
@ -1,6 +1,12 @@
|
||||||
Version 1.3.39 (in progress)
|
Version 1.3.39 (in progress)
|
||||||
============================
|
============================
|
||||||
|
|
||||||
|
2008-03-01: bhy
|
||||||
|
[Python] Some fixes for Python 3.0.1 and higher support. In 3.0.1, the C API function
|
||||||
|
PyObject_Compare is removed, so PyObject_RichCompareBool is used for replacement.
|
||||||
|
Struct initilization of SwigPyObject and SwigPyObject_as_number changed to reflect
|
||||||
|
the drop of tp_compare and nb_long.
|
||||||
|
|
||||||
2008-03-01: bhy
|
2008-03-01: bhy
|
||||||
[Python] Fix SF#2583160. Now the importer in Python shadow wrapper take care of the
|
[Python] Fix SF#2583160. Now the importer in Python shadow wrapper take care of the
|
||||||
case that module already imported at other place.
|
case that module already imported at other place.
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,5 @@
|
||||||
|
|
||||||
from swigobject import *
|
from swigobject import *
|
||||||
from string import replace
|
|
||||||
from string import upper
|
|
||||||
from string import lstrip
|
|
||||||
|
|
||||||
a = A()
|
a = A()
|
||||||
|
|
||||||
|
|
@ -17,12 +14,12 @@ if a1.this != a2.this:
|
||||||
lthis = long(a.this)
|
lthis = long(a.this)
|
||||||
# match pointer value, but deal with leading zeros on 8/16 bit systems and different C++ compilers interpretation of %p
|
# match pointer value, but deal with leading zeros on 8/16 bit systems and different C++ compilers interpretation of %p
|
||||||
xstr1 = "%016X" % (lthis,)
|
xstr1 = "%016X" % (lthis,)
|
||||||
xstr1 = lstrip(xstr1, '0')
|
xstr1 = str.lstrip(xstr1, '0')
|
||||||
xstr2 = pointer_str(a)
|
xstr2 = pointer_str(a)
|
||||||
xstr2 = replace(xstr2, "0x", "")
|
xstr2 = str.replace(xstr2, "0x", "")
|
||||||
xstr2 = replace(xstr2, "0X", "")
|
xstr2 = str.replace(xstr2, "0X", "")
|
||||||
xstr2 = lstrip(xstr2, '0')
|
xstr2 = str.lstrip(xstr2, '0')
|
||||||
xstr2 = upper(xstr2)
|
xstr2 = str.upper(xstr2)
|
||||||
|
|
||||||
if xstr1 != xstr2:
|
if xstr1 != xstr2:
|
||||||
print xstr1, xstr2
|
print xstr1, xstr2
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ namespace std {
|
||||||
{
|
{
|
||||||
bool res;
|
bool res;
|
||||||
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
|
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
|
||||||
res = PyObject_Compare(v, w) < 0;
|
res = PyObject_RichCompareBool(v, w, Py_LT);
|
||||||
/* This may fall into a case of inconsistent
|
/* This may fall into a case of inconsistent
|
||||||
eg. ObjA > ObjX > ObjB
|
eg. ObjA > ObjX > ObjB
|
||||||
but ObjA < ObjB
|
but ObjA < ObjB
|
||||||
|
|
|
||||||
|
|
@ -660,7 +660,11 @@ _PySwigObject_type(void) {
|
||||||
0, /*nb_coerce*/
|
0, /*nb_coerce*/
|
||||||
#endif
|
#endif
|
||||||
(unaryfunc)SwigPyObject_long, /*nb_int*/
|
(unaryfunc)SwigPyObject_long, /*nb_int*/
|
||||||
|
#if PY_VERSION_HEX < 0x03000000
|
||||||
(unaryfunc)SwigPyObject_long, /*nb_long*/
|
(unaryfunc)SwigPyObject_long, /*nb_long*/
|
||||||
|
#else
|
||||||
|
0, /*nb_reserved*/
|
||||||
|
#endif
|
||||||
(unaryfunc)0, /*nb_float*/
|
(unaryfunc)0, /*nb_float*/
|
||||||
#if PY_VERSION_HEX < 0x03000000
|
#if PY_VERSION_HEX < 0x03000000
|
||||||
(unaryfunc)SwigPyObject_oct, /*nb_oct*/
|
(unaryfunc)SwigPyObject_oct, /*nb_oct*/
|
||||||
|
|
@ -700,7 +704,11 @@ _PySwigObject_type(void) {
|
||||||
(getattrfunc)0, /* tp_getattr */
|
(getattrfunc)0, /* tp_getattr */
|
||||||
#endif
|
#endif
|
||||||
(setattrfunc)0, /* tp_setattr */
|
(setattrfunc)0, /* tp_setattr */
|
||||||
(cmpfunc)SwigPyObject_compare, /* tp_compare */
|
#if PY_VERSION_HEX >= 0x03000000
|
||||||
|
0, /* tp_reserved in 3.0.1 */
|
||||||
|
#else
|
||||||
|
(cmpfunc)SwigPyObject_compare, /* tp_compare */
|
||||||
|
#endif
|
||||||
(reprfunc)SwigPyObject_repr, /* tp_repr */
|
(reprfunc)SwigPyObject_repr, /* tp_repr */
|
||||||
&SwigPyObject_as_number, /* tp_as_number */
|
&SwigPyObject_as_number, /* tp_as_number */
|
||||||
0, /* tp_as_sequence */
|
0, /* tp_as_sequence */
|
||||||
|
|
@ -871,14 +879,18 @@ _PySwigPacked_type(void) {
|
||||||
(printfunc)SwigPyPacked_print, /* tp_print */
|
(printfunc)SwigPyPacked_print, /* tp_print */
|
||||||
(getattrfunc)0, /* tp_getattr */
|
(getattrfunc)0, /* tp_getattr */
|
||||||
(setattrfunc)0, /* tp_setattr */
|
(setattrfunc)0, /* tp_setattr */
|
||||||
(cmpfunc)SwigPyPacked_compare, /* tp_compare */
|
#if PY_VERSION_HEX>=0x03000000
|
||||||
(reprfunc)SwigPyPacked_repr, /* tp_repr */
|
0, /* tp_reserved in 3.0.1 */
|
||||||
0, /* tp_as_number */
|
#else
|
||||||
|
(cmpfunc)SwigPyPacked_compare, /* tp_compare */
|
||||||
|
#endif
|
||||||
|
(reprfunc)SwigPyPacked_repr, /* tp_repr */
|
||||||
|
0, /* tp_as_number */
|
||||||
0, /* tp_as_sequence */
|
0, /* tp_as_sequence */
|
||||||
0, /* tp_as_mapping */
|
0, /* tp_as_mapping */
|
||||||
(hashfunc)0, /* tp_hash */
|
(hashfunc)0, /* tp_hash */
|
||||||
(ternaryfunc)0, /* tp_call */
|
(ternaryfunc)0, /* tp_call */
|
||||||
(reprfunc)SwigPyPacked_str, /* tp_str */
|
(reprfunc)SwigPyPacked_str, /* tp_str */
|
||||||
PyObject_GenericGetAttr, /* tp_getattro */
|
PyObject_GenericGetAttr, /* tp_getattro */
|
||||||
0, /* tp_setattro */
|
0, /* tp_setattro */
|
||||||
0, /* tp_as_buffer */
|
0, /* tp_as_buffer */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue