Merge branch 'amaeldoe-master'
* amaeldoe-master: Add python runtime test for dynamically added attributes Attribute of SWIG wrapped classes instances were overwritten on __init__() Fix SwigPyObject->dict memory leak Make __dict__ accessible for Python builtin classes
This commit is contained in:
commit
b886a54fce
4 changed files with 56 additions and 3 deletions
|
|
@ -9,6 +9,7 @@ SWIGINTERN void \
|
|||
wrapper##_closure(PyObject *a) { \
|
||||
SwigPyObject *sobj; \
|
||||
sobj = (SwigPyObject *)a; \
|
||||
Py_XDECREF(sobj->dict); \
|
||||
if (sobj->own) { \
|
||||
PyObject *o = wrapper(a, NULL); \
|
||||
Py_XDECREF(o); \
|
||||
|
|
|
|||
|
|
@ -381,6 +381,23 @@ typedef struct {
|
|||
#endif
|
||||
} SwigPyObject;
|
||||
|
||||
|
||||
#ifdef SWIGPYTHON_BUILTIN
|
||||
|
||||
SWIGRUNTIME PyObject *
|
||||
SwigPyObject_get___dict__(PyObject *v, PyObject *SWIGUNUSEDPARM(args))
|
||||
{
|
||||
SwigPyObject *sobj = (SwigPyObject *)v;
|
||||
|
||||
if (!sobj->dict)
|
||||
sobj->dict = PyDict_New();
|
||||
|
||||
Py_INCREF(sobj->dict);
|
||||
return sobj->dict;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
SWIGRUNTIME PyObject *
|
||||
SwigPyObject_long(SwigPyObject *v)
|
||||
{
|
||||
|
|
@ -1420,18 +1437,21 @@ SWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int f
|
|||
newobj = (SwigPyObject *) newobj->next;
|
||||
newobj->next = next_self;
|
||||
newobj = (SwigPyObject *)next_self;
|
||||
#ifdef SWIGPYTHON_BUILTIN
|
||||
newobj->dict = 0;
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
newobj = PyObject_New(SwigPyObject, clientdata->pytype);
|
||||
#ifdef SWIGPYTHON_BUILTIN
|
||||
newobj->dict = 0;
|
||||
#endif
|
||||
}
|
||||
if (newobj) {
|
||||
newobj->ptr = ptr;
|
||||
newobj->ty = type;
|
||||
newobj->own = own;
|
||||
newobj->next = 0;
|
||||
#ifdef SWIGPYTHON_BUILTIN
|
||||
newobj->dict = 0;
|
||||
#endif
|
||||
return (PyObject*) newobj;
|
||||
}
|
||||
return SWIG_Py_Void();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue