Mailing List Archive

[issue5096] strange thing after call PyObject_CallMethod
New submission from Kandalintsev Alexandre <bug_hunter@messir.net>:

When unhandled in python code exception occurs in PyObject_CallMethod
frame_dealloc() (Objects/frameobject.c:422)
not called. Even if I call PyErr_Print().

But if I call PyErr_Clear() then all okay. Documentation says that both
this functions doing same work(http://docs.python.org/3.0/c-api/
exceptions.html). As we see thats not true or not all nuances documented.

Examples and more on this mailing list:
http://groups.google.com/group/comp.lang.python/browse_thread/
thread/19316b3effa37d2d

----------
components: Interpreter Core
messages: 80757
nosy: exe
severity: normal
status: open
title: strange thing after call PyObject_CallMethod
type: behavior
versions: Python 3.0, Python 3.1

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue5096>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue5096] strange thing after call PyObject_CallMethod [ In reply to ]
Amaury Forgeot d'Arc <amauryfa@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@bugs.python.org>
<http://bugs.python.org/issue5096>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue5096] strange thing after call PyObject_CallMethod [ In reply to ]
Kandalintsev Alexandre <bug_hunter@messir.net> added the comment:

Thank you for your activity. This feature drank alot of my blood. Please
document this or change behavior.

PS Older python versions may be also affected so changing behavior may
brake existing code :(

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue5096>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue5096] strange thing after call PyObject_CallMethod [ In reply to ]
Changes by Amaury Forgeot d'Arc <amauryfa@gmail.com>:


----------
assignee: -> georg.brandl
components: +Documentation -Interpreter Core
nosy: +georg.brandl

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue5096>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue5096] strange thing after call PyObject_CallMethod [ In reply to ]
Georg Brandl <georg@python.org> added the comment:

Documented PyErr_PrintEx() in r69292.

----------
resolution: -> fixed
status: open -> closed

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue5096>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com