Fix assert in PyTuple_GET_SIZE

Occurs in debug interpreter builds of python-3.7 when calling tp_new in
a few testcases such as Examples/python/extend.

Closes #1321
This commit is contained in:
Andreas Gaeer 2018-09-03 19:52:43 +01:00 committed by William S Fulton
commit 0165180735
2 changed files with 12 additions and 4 deletions

View file

@ -1254,10 +1254,14 @@ SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this)
}
} else {
#if PY_VERSION_HEX >= 0x03000000
inst = ((PyTypeObject*) data->newargs)->tp_new((PyTypeObject*) data->newargs, Py_None, Py_None);
if (inst) {
PyObject_SetAttr(inst, SWIG_This(), swig_this);
Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG;
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;
}
}
#else
PyObject *dict = PyDict_New();