Better error checking when setting 'this' in Python
If python_append.i is modified to use: __slots__ = [] instead of __slots__ = ["this"] then this additional error checking prevents a crash and shows a stack trace and error: AttributeError: 'ForSlots' object has no attribute 'this' Related to issue #1674
This commit is contained in:
parent
a01e8474f6
commit
94b4c7dc21
1 changed files with 5 additions and 5 deletions
|
|
@ -1245,7 +1245,7 @@ SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this)
|
||||||
return inst;
|
return inst;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWIGRUNTIME void
|
SWIGRUNTIME int
|
||||||
SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this)
|
SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this)
|
||||||
{
|
{
|
||||||
#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
|
#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
|
||||||
|
|
@ -1256,11 +1256,10 @@ SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this)
|
||||||
dict = PyDict_New();
|
dict = PyDict_New();
|
||||||
*dictptr = dict;
|
*dictptr = dict;
|
||||||
}
|
}
|
||||||
PyDict_SetItem(dict, SWIG_This(), swig_this);
|
return PyDict_SetItem(dict, SWIG_This(), swig_this);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
PyObject_SetAttr(inst, SWIG_This(), swig_this);
|
return PyObject_SetAttr(inst, SWIG_This(), swig_this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1274,7 +1273,8 @@ SWIG_Python_InitShadowInstance(PyObject *args) {
|
||||||
if (sthis) {
|
if (sthis) {
|
||||||
SwigPyObject_append((PyObject*) sthis, obj[1]);
|
SwigPyObject_append((PyObject*) sthis, obj[1]);
|
||||||
} else {
|
} else {
|
||||||
SWIG_Python_SetSwigThis(obj[0], obj[1]);
|
if (SWIG_Python_SetSwigThis(obj[0], obj[1]) != 0)
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
return SWIG_Py_Void();
|
return SWIG_Py_Void();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue