Staging
v0.8.1
https://github.com/python/cpython
Revision c572dc3752871a48127db1fb3c8bc20889d2be34 authored by Amaury Forgeot d'Arc on 13 November 2007, 22:43:05 UTC, committed by Amaury Forgeot d'Arc on 13 November 2007, 22:43:05 UTC
When an unfinished generator-iterator is garbage collected, PyEval_EvalFrameEx
is called with a GeneratorExit exception set.  This leads to funny results
if the sys.settrace function itself makes use of generators.
A visible effect is that the settrace function is reset to None.
Another is that the eventual "finally" block of the generator is not called.

It is necessary to save/restore the exception around the call to the trace
function.

This happens a lot with py3k: isinstance() of an ABCMeta instance runs
    def __instancecheck__(cls, instance):
        """Override for isinstance(instance, cls)."""
        return any(cls.__subclasscheck__(c)
                   for c in {instance.__class__, type(instance)})
which lets an opened generator expression each time it returns True.

And the problem can be reproduced in 2.5 with pure python code.
1 parent f5ccd45
History
Tip revision: c572dc3752871a48127db1fb3c8bc20889d2be34 authored by Amaury Forgeot d'Arc on 13 November 2007, 22:43:05 UTC
Backport for issue1265 (pdb bug with "with" statement).
Tip revision: c572dc3
File Mode Size
Demo
Doc
Grammar
Include
Lib
Mac
Misc
Modules
Objects
PC
PCbuild
PCbuild8
Parser
Python
RISCOS
Tools
.hgtags -rw-r--r-- 3.4 KB
LICENSE -rw-r--r-- 13.4 KB
Makefile.pre.in -rw-r--r-- 34.5 KB
README -rw-r--r-- 54.4 KB
configure -rwxr-xr-x 610.5 KB
configure.in -rw-r--r-- 95.3 KB
install-sh -rwxr-xr-x 7.0 KB
pyconfig.h.in -rw-r--r-- 26.5 KB
setup.py -rw-r--r-- 67.2 KB

README

back to top