diff --git a/CHANGES.current b/CHANGES.current index d02337781..e1dafdc34 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release. Version 3.0.0 (in progress) ============================ +2014-03-01: wsfulton + [Python] Patch #143 Fix type shown when using type() to include the module and package + name when using -builtin. + 2014-03-01: wsfulton [Python] SF patch #347 Fix missing argument count checking with -modern. Fixes regression introduced when builtin changes were introduced in SWIG-2.0.3. diff --git a/Examples/python/import_packages/same_modnames1/runme.py b/Examples/python/import_packages/same_modnames1/runme.py index 9cdb95caf..923f0e0bb 100644 --- a/Examples/python/import_packages/same_modnames1/runme.py +++ b/Examples/python/import_packages/same_modnames1/runme.py @@ -4,4 +4,6 @@ import pkg2.foo print " Finished importing pkg2.foo" var2 = pkg2.foo.Pkg2_Foo() +if str(type(var2)).find("'pkg2.foo.Pkg2_Foo'") == -1: + raise RuntimeError("failed type checking: " + str(type(var2))) print " Successfully created object pkg2.foo.Pkg2_Foo" diff --git a/Examples/python/import_packages/same_modnames2/runme.py b/Examples/python/import_packages/same_modnames2/runme.py index bde4305c4..af8f78194 100644 --- a/Examples/python/import_packages/same_modnames2/runme.py +++ b/Examples/python/import_packages/same_modnames2/runme.py @@ -1,4 +1,7 @@ import pkg1.pkg2.foo print " Finished importing pkg1.pkg2.foo" + var2 = pkg1.pkg2.foo.Pkg2_Foo(); +if str(type(var2)).find("'pkg1.pkg2.foo.Pkg2_Foo'") == -1: + raise RuntimeError("failed type checking: " + str(type(var2))) print " Successfully created object pkg1.pkg2.foo.Pkg2_Foo" diff --git a/Examples/test-suite/python/namespace_class_runme.py b/Examples/test-suite/python/namespace_class_runme.py index 84d3b00ed..d139527b7 100644 --- a/Examples/test-suite/python/namespace_class_runme.py +++ b/Examples/test-suite/python/namespace_class_runme.py @@ -32,3 +32,7 @@ f.moo(1) f = FooT_H() f.foo(Hi) + +f_type = str(type(f)) +if f_type.find("'namespace_class.FooT_H'") == -1: + raise RuntimeError("Incorrect type: " + f_type) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 7c1595da2..13ddbfb61 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -3592,11 +3592,19 @@ public: if (GetFlag(n, "feature:python:nondynamic")) Setattr(n, "feature:python:tp_setattro", "SWIG_Python_NonDynamicSetAttr"); + Node *mod = Getattr(n, "module"); + String *modname = mod ? Getattr(mod, "name") : 0; String *quoted_symname; if (package) { - quoted_symname = NewStringf("\"%s.%s\"", package, symname); + if (modname) + quoted_symname = NewStringf("\"%s.%s.%s\"", package, modname, symname); + else + quoted_symname = NewStringf("\"%s.%s\"", package, symname); } else { - quoted_symname = NewStringf("\"%s\"", symname); + if (modname) + quoted_symname = NewStringf("\"%s.%s\"", modname, symname); + else + quoted_symname = NewStringf("\"%s\"", symname); } String *quoted_rname = NewStringf("\"%s\"", rname); char const *tp_init = builtin_tp_init ? Char(builtin_tp_init) : Swig_directorclass(n) ? "0" : "SwigPyBuiltin_BadInit";