From 76229dbab8be7411edc851af2df21c3d082e5b33 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 22 Jan 2008 23:33:59 +0000 Subject: [PATCH] Restore containers accepting NULL pointers when used in overloaded methods - problem reported by Josh Cherry git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10217 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/python/li_std_vector.i | 2 ++ Examples/test-suite/python/li_std_vector_runme.py | 9 +++++++++ Lib/python/pycontainer.swg | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/python/li_std_vector.i b/Examples/test-suite/python/li_std_vector.i index d1af1a70a..06dafce59 100644 --- a/Examples/test-suite/python/li_std_vector.i +++ b/Examples/test-suite/python/li_std_vector.i @@ -135,5 +135,7 @@ std::string overloaded1(std::vector vi) { return "vector"; } std::string overloaded1(std::vector vi) { return "vector"; } std::string overloaded2(std::vector vi) { return "vector"; } std::string overloaded2(std::vector vi) { return "vector"; } +std::string overloaded3(std::vector *vi) { return "vector *"; } +std::string overloaded3(int i) { return "int"; } %} diff --git a/Examples/test-suite/python/li_std_vector_runme.py b/Examples/test-suite/python/li_std_vector_runme.py index a811fc49b..a0d96d4aa 100644 --- a/Examples/test-suite/python/li_std_vector_runme.py +++ b/Examples/test-suite/python/li_std_vector_runme.py @@ -124,3 +124,12 @@ if overloaded2(iv) != "vector": if overloaded2(dv) != "vector": raise RuntimeError +if overloaded3(iv) != "vector *": + raise RuntimeError + +if overloaded3(None) != "vector *": + raise RuntimeError + +if overloaded3(100) != "int": + raise RuntimeError + diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index 7b8e56e6d..b68a11f06 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -702,7 +702,7 @@ namespace swig { typedef T value_type; static int asptr(PyObject *obj, sequence **seq) { - if (SWIG_Python_GetSwigThis(obj)) { + if (obj == Py_None || SWIG_Python_GetSwigThis(obj)) { sequence *p; if (SWIG_ConvertPtr(obj,(void**)&p, swig::type_info(),0) == SWIG_OK) {