Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

[issue14718] In the generator's try/finally statement a runtime error occurs when the generator is not exhausted

 

 

Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

May 3, 2012, 3:22 PM

Post #1 of 2 (85 views)
Permalink
[issue14718] In the generator's try/finally statement a runtime error occurs when the generator is not exhausted

New submission from py.user <bugzilla-mail-box [at] yandex>:

http://www.python.org/dev/peps/pep-0342/
" 6. Allow "yield" to be used in try/finally blocks, since garbage
collection or an explicit close() call would now allow the
finally clause to execute."

"New syntax: yield allowed inside try-finally

The syntax for generator functions is extended to allow a
yield-statement inside a try-finally statement."


>>> def f():
... try:
... yield 1
... yield 2
... yield 3
... finally:
... yield 4
...
>>> g = f()
>>> next(g)
1
>>> next(g)
2
>>> g = f()
Exception RuntimeError: 'generator ignored GeneratorExit' in <generator object f at 0xb74d2504> ignored
>>>

----------
components: Interpreter Core
messages: 159883
nosy: py.user
priority: normal
severity: normal
status: open
title: In the generator's try/finally statement a runtime error occurs when the generator is not exhausted
type: behavior
versions: Python 3.2

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14718>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

May 3, 2012, 3:33 PM

Post #2 of 2 (81 views)
Permalink
[issue14718] In the generator's try/finally statement a runtime error occurs when the generator is not exhausted [In reply to]

Benjamin Peterson <benjamin [at] python> added the comment:

It means in the body of the try statement.

----------
nosy: +benjamin.peterson
resolution: -> invalid
status: open -> closed

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14718>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.