[pypy-issue] [issue1126] __exit__ is not called when an exception raised inside of generator

Hong Minhee tracker at bugs.pypy.org
Thu Apr 12 04:15:19 CEST 2012


New submission from Hong Minhee <minhee at dahlia.kr>:

It seems that PyPy does not call __exit__ of context used inside generator when an 
exception raised.

Complicated to explain, so I attached a code that reproduces this bug.  It works 
correctly on CPython 2.7 but not on PyPy 1.8.

    $ python2.7 reprod.py 
    2.7.3 (default, Apr 10 2012, 12:29:04) 
    [GCC 4.6.3]
    inner: (<type 'exceptions.GeneratorExit'>, GeneratorExit(), <traceback object at 
0xc0dfc8>)
    outer: (<type 'exceptions.Exception'>, Exception(), <traceback object at 
0xc0dfc8>)
    dirty = False

    $ pypy reprod.py 
    2.7.2 (1.8+dfsg-2, Feb 19 2012, 19:18:08)
    [PyPy 1.8.0 with GCC 4.6.2]
    outer: (<type 'exceptions.Exception'>, Exception(), <traceback object at 
0x00007f4ca70c6b20>)
    dirty = True

Thanks.

----------
files: reprod.py
messages: 4245
nosy: pypy-issue
priority: bug
status: unread
title: __exit__ is not called when an exception raised inside of generator

________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue1126>
________________________________________


More information about the pypy-issue mailing list