]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
Correction for issue1265 (pdb bug with "with" statement).
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>
Tue, 13 Nov 2007 01:05:30 +0000 (01:05 +0000)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>
Tue, 13 Nov 2007 01:05:30 +0000 (01:05 +0000)
commitf05149a257560144cbaaea3e96c404803dbf26e4
treec2f858ed25b8db3a0f90905fbc4c7b5e4089e9f1
parent8161a65cd865b6be4d1269791ff7c71c158c699b
Correction for issue1265 (pdb bug with "with" statement).

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.

Seems a backport candidate, even if the case is less frequent in 2.5.
Lib/test/test_trace.py
Python/ceval.c