[pypy-issue] [issue736] 'finally' suite not invoked in generator function

Jonas H. tracker at bugs.pypy.org
Fri Jun 3 15:07:37 CEST 2011


New submission from Jonas H. <jonas at lophus.org>:

Consider this code sample:


def g():
    try:
        yield 1
    finally:
        print 'finally'

g().next()

CPython behaves differently from PyPy:

$ python2.7 asd.py 
finally
---
$ pypy asd.py
---

The finally suite is executed only if the generator is exhausted in such way 
that StopIteration is raised.

----------
messages: 2591
nosy: jonash, pypy-issue
priority: bug
status: unread
title: 'finally' suite not invoked in generator function

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


More information about the pypy-issue mailing list