From 040683d1b37da744635138b64f20303664465211 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 6 Sep 2018 21:07:59 +0100 Subject: [PATCH] Fix Python -builtin and -fastdispatch regression. Generated code did not compile --- Source/Modules/python.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index b3dbe19ab..9861ddee6 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -2580,7 +2580,11 @@ public: if (castmode) { dispatch = Swig_overload_dispatch_cast(n, dispatch_code, &maxargs); } else { - String *fastdispatch_code = NewStringf("PyObject *retobj = %s\nif (!SWIG_Python_TypeErrorOccurred(retobj)) return retobj;\nSWIG_fail;", dispatch_call); + String *fastdispatch_code; + if (builtin_ctor) + fastdispatch_code = NewStringf("int retval = %s\nif (retval == 0 || !SWIG_Python_TypeErrorOccurred(NULL)) return retval;\nSWIG_fail;", dispatch_call); + else + fastdispatch_code = NewStringf("PyObject *retobj = %s\nif (!SWIG_Python_TypeErrorOccurred(retobj)) return retobj;\nSWIG_fail;", dispatch_call); if (!CPlusPlus) { Insert(fastdispatch_code, 0, "{\n"); Append(fastdispatch_code, "\n}");