[Python-Dev] Is it safe to call PyEval_EvalFrameEx() with an exception set? (original) (raw)
Victor Stinner victor.stinner at gmail.com
Tue Jul 16 12:08:11 CEST 2013
- Previous message: [Python-Dev] Is it safe to call PyEval_EvalFrameEx() with an exception set?
- Next message: [Python-Dev] Is it safe to call PyEval_EvalFrameEx() with an exception set?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
2013/7/16 Antoine Pitrou <solipsis at pitrou.net>:
Le Tue, 16 Jul 2013 02:34:49 +0200, Victor Stinner <victor.stinner at gmail.com> a écrit :
I would like to add assertions in Python/ceval.c to detect such bugs earlier. The problem is that some functions rely on the ability to call PyEvalEvalFrameEx() with an exception set. Is it expected? Should it be avoided? Well, if your frame is a generator frame, you must be able to throw() into it, i.e. resume it with an exception set. The difficulty here is that there are different meanings for "an exception is set": - PyErrOccurred() is true - the fexctype field and friends are set - possibly another one that I'm forgetting about
Ah yes, a generator can call PyEval_EvalFrameEx() with an exception set (PyErr_Occurred() is non-NULL), but it sets throwflag to 1.
My question is when an exception is set (PyErr_Occurred() is non-NULL) at the beginning of the bytecode evaluation loop. Just after the "goto error;" in this extract of ceval.c:
if (throwflag) /* support for generator.throw() */
goto error;
for (;;) { ... }
Victor
- Previous message: [Python-Dev] Is it safe to call PyEval_EvalFrameEx() with an exception set?
- Next message: [Python-Dev] Is it safe to call PyEval_EvalFrameEx() with an exception set?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]