diff --git a/SWIG/Examples/test-suite/python/callback_runme.py b/SWIG/Examples/test-suite/python/callback_runme.py index ca16de664..b2bbb2d0f 100644 --- a/SWIG/Examples/test-suite/python/callback_runme.py +++ b/SWIG/Examples/test-suite/python/callback_runme.py @@ -4,7 +4,7 @@ from callback import * if foo(2) != 2: raise RuntimeError -if A.bar(2) != 4: +if A_bar(2) != 4: raise RuntimeError if foobar(3, _callback.foo) != foo(3): @@ -13,7 +13,7 @@ if foobar(3, _callback.foo) != foo(3): if foobar(3, foo) != foo(3): raise RuntimeError -if foobar(3, A.bar) != A.bar(3): +if foobar(3, A_bar) != A_bar(3): raise RuntimeError if foobar(3, foof) != foof(3): diff --git a/SWIG/Examples/test-suite/python/default_args_runme.py b/SWIG/Examples/test-suite/python/default_args_runme.py index 2251dacaa..091a92376 100644 --- a/SWIG/Examples/test-suite/python/default_args_runme.py +++ b/SWIG/Examples/test-suite/python/default_args_runme.py @@ -1,7 +1,7 @@ import default_args -if default_args.Statics.staticMethod() != 60: +if default_args.Statics_staticMethod() != 60: raise RuntimeError if default_args.cfunc1(1) != 2: diff --git a/SWIG/Examples/test-suite/python/director_abstract_runme.py b/SWIG/Examples/test-suite/python/director_abstract_runme.py index 7e03beb9f..26d4c8883 100644 --- a/SWIG/Examples/test-suite/python/director_abstract_runme.py +++ b/SWIG/Examples/test-suite/python/director_abstract_runme.py @@ -29,7 +29,7 @@ class MyExample3(director_abstract.Example3_i): return b me1 = MyExample1() -if MyExample1.get_color(me1, 1,2,3) != 1: +if MyExample1_get_color(me1, 1,2,3) != 1: raise RuntimeError me2 = MyExample2(1,2) diff --git a/SWIG/Examples/test-suite/python/director_nested_runme.py b/SWIG/Examples/test-suite/python/director_nested_runme.py index 8bc74ad7a..cff82f55b 100644 --- a/SWIG/Examples/test-suite/python/director_nested_runme.py +++ b/SWIG/Examples/test-suite/python/director_nested_runme.py @@ -53,7 +53,7 @@ class C(FooBar_int): pass cc = C() -c = C.get_self(cc) +c = FooBar_int_get_self(cc) c.advance() if c.get_name() != "FooBar::get_name hello": diff --git a/SWIG/Examples/test-suite/python/kwargs_runme.py b/SWIG/Examples/test-suite/python/kwargs_runme.py index 2c4af01de..9546730f7 100644 --- a/SWIG/Examples/test-suite/python/kwargs_runme.py +++ b/SWIG/Examples/test-suite/python/kwargs_runme.py @@ -14,13 +14,13 @@ f = Foo(b=2,a=1) if f.foo(b=1,a=2) != 3: raise RuntimeError -if Foo.statfoo(b=2) != 3: +if Foo_statfoo(b=2) != 3: raise RuntimeError if f.efoo(b=2) != 3: raise RuntimeError -if Foo.sfoo(b=2) != 3: +if Foo_sfoo(b=2) != 3: raise RuntimeError @@ -30,13 +30,13 @@ b = BarInt(b=2,a=1) if b.bar(b=1,a=2) != 3: raise RuntimeError -if BarInt.statbar(b=2) != 3: +if BarInt_statbar(b=2) != 3: raise RuntimeError if b.ebar(b=2) != 3: raise RuntimeError -if BarInt.sbar(b=2) != 3: +if BarInt_sbar(b=2) != 3: raise RuntimeError diff --git a/SWIG/Examples/test-suite/python/li_factory_runme.py b/SWIG/Examples/test-suite/python/li_factory_runme.py index ce0e3caef..f6aa73864 100644 --- a/SWIG/Examples/test-suite/python/li_factory_runme.py +++ b/SWIG/Examples/test-suite/python/li_factory_runme.py @@ -5,7 +5,7 @@ r = circle.radius() if (r != 1.5): raise RuntimeError -point = Geometry.create(Geometry.POINT) +point = Geometry_create(Geometry.POINT) w = point.width() if (w != 1.0): raise RuntimeError diff --git a/SWIG/Examples/test-suite/python/overload_template_runme.py b/SWIG/Examples/test-suite/python/overload_template_runme.py index ed1b7fa1d..3fd77f339 100644 --- a/SWIG/Examples/test-suite/python/overload_template_runme.py +++ b/SWIG/Examples/test-suite/python/overload_template_runme.py @@ -140,6 +140,6 @@ if (nsoverload() != 1050): raise RuntimeError, ("nsoverload(const char *)") -A.foo(1) +A_foo(1) b = B() b.foo(1) diff --git a/SWIG/Examples/test-suite/python/template_static_runme.py b/SWIG/Examples/test-suite/python/template_static_runme.py index 226d675ee..9171d93b5 100644 --- a/SWIG/Examples/test-suite/python/template_static_runme.py +++ b/SWIG/Examples/test-suite/python/template_static_runme.py @@ -1,3 +1,3 @@ from template_static import * -Foo.bar_double(1) +Foo_bar_double(1) diff --git a/SWIG/Lib/python/pyrun.swg b/SWIG/Lib/python/pyrun.swg index 9f92727fa..2f0b88f1d 100644 --- a/SWIG/Lib/python/pyrun.swg +++ b/SWIG/Lib/python/pyrun.swg @@ -1134,6 +1134,14 @@ SWIG_Python_NewShadowInstance(PySwigClientData *data, PyObject *swig_this) Py_DECREF(dict); } return inst; +#else +#if (PY_VERSION_HEX >= 0x02010000) + PyObject *inst; + PyObject *dict = PyDict_New(); + PyDict_SetItem(dict, SWIG_This(), swig_this); + inst = PyInstance_NewRaw(data->newargs, dict); + Py_DECREF(dict); + return (PyObject *) inst; #else PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type); if (inst == NULL) { @@ -1146,9 +1154,16 @@ SWIG_Python_NewShadowInstance(PySwigClientData *data, PyObject *swig_this) Py_DECREF(inst); return NULL; } +#ifdef Py_TPFLAGS_HAVE_WEAKREFS + inst->in_weakreflist = NULL; +#endif +#ifdef Py_TPFLAGS_GC + PyObject_GC_Init(inst); +#endif PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this); return (PyObject *) inst; #endif +#endif } /* Create a new pointer object */