2013/7/16 Antoine Pitrou <solip...@pitrou.net>: > Le Tue, 16 Jul 2013 02:34:49 +0200, > Victor Stinner <victor.stin...@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 PyEval_EvalFrameEx() 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": > - PyErr_Occurred() is true > - the f_exc_type 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 _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com