From 3208ff2bf54f523da3b0fd849df3cf7e686771fa Mon Sep 17 00:00:00 2001 From: Christian Landsiedel Date: Thu, 22 Nov 2018 14:24:49 +0100 Subject: [PATCH] fix for creating new shadow class in python 3.6 --- Lib/python/pyrun.swg | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 7386ff7e2..650e30d3e 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -1205,12 +1205,16 @@ SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) #if PY_VERSION_HEX >= 0x03000000 PyObject *empty_args = PyTuple_New(0); if (empty_args) { - inst = ((PyTypeObject *)data->newargs)->tp_new((PyTypeObject *)data->newargs, empty_args, Py_None); - Py_DECREF(empty_args); - if (inst) { - PyObject_SetAttr(inst, SWIG_This(), swig_this); - Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; + PyObject *empty_kwargs = PyDict_New(); + if (empty_kwargs) { + inst = ((PyTypeObject *)data->newargs)->tp_new((PyTypeObject *)data->newargs, empty_args, empty_kwargs); + Py_DECREF(empty_kwargs); + if (inst) { + PyObject_SetAttr(inst, SWIG_This(), swig_this); + Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; + } } + Py_DECREF(empty_args); } #else PyObject *dict = PyDict_New();