Issue 14718: In the generator's try/finally statement a runtime error occurs when the generator is not exhausted (original) (raw)
Issue14718
Created on 2012-05-03 22:22 by py.user, last changed 2022-04-11 14:57 by admin. This issue is now closed.
| Messages (2) | ||
|---|---|---|
| msg159883 - (view) | Author: py.user (py.user) * | Date: 2012-05-03 22:22 |
| 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 >>> | ||
| msg159884 - (view) | Author: Benjamin Peterson (benjamin.peterson) * ![]() |
Date: 2012-05-03 22:33 |
| It means in the body of the try statement. |
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:57:29 | admin | set | github: 58923 |
| 2012-05-03 22:33:17 | benjamin.peterson | set | status: open -> closednosy: + benjamin.petersonmessages: + resolution: not a bug |
| 2012-05-03 22:22:22 | py.user | create |
