[issue1692335] Fix exception pickling: Move initial args assignment to BaseException.__new__
Richard Oudkerk
report at bugs.python.org
Fri Jul 27 21:00:41 CEST 2012
Richard Oudkerk <shibturn at gmail.com> added the comment:
> Or you could simply Py_INCREF(args) before the Py_XDECREF...
But won't self->args point to a broken object while any callbacks triggered by Py_XDECREF() are run?
An alternative would be
tmp = self->args;
self->args = args;
Py_INCREF(self->args);
Py_XDECREF(tmp);
As far as I can see the idiom Py_?DECREF(self->...) is rarely safe outside of a deallocator unless you are sure the pointed to object has a "safe" type (or you are sure the refcount cannot fall to zero).
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue1692335>
_______________________________________
More information about the Python-bugs-list
mailing list