[issue5096] strange thing after call PyObject_CallMethod
Amaury Forgeot d'Arc
report at bugs.python.org
Thu Jan 29 13:06:33 CET 2009
Amaury Forgeot d'Arc <amauryfa at gmail.com> added the comment:
I think I have an explanation:
When a python exception is raised, the current call stack is stored in
the exception state (tstate->curexc_traceback). This includes all the
living frame objects, with all their local variables.
This explains why frame_dealloc is not called at this time, and why the
"self" object has its refcount increased.
PyErr_Clear() releases everything.
PyErr_Print() does clear tstate->curexc_traceback, but only to copy the
value into sys.last_traceback; So the frame object is still alive.
I suggest you to use PyErr_PrintEx(0), which will print and clear the
error, but not store the exception info into the sys.last_* variables.
[PyErr_Print() simply calls PyErr_PrintEx(1); No, it's not yet documented]
----------
nosy: +amaury.forgeotdarc
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5096>
_______________________________________
More information about the Python-bugs-list
mailing list