Title: Generator bug allows you to chain arbitrary tracebacks to the next raised exception
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.1, Python 3.2
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: pitrou Nosy List: Devin Jeanpierre, ncoghlan, pitrou, python-dev
Priority: normal Keywords:

Created on 2011-07-03 07:07 by Devin Jeanpierre, last changed 2011-07-03 18:44 by python-dev. This issue is now closed.

File name Uploaded Description Edit Devin Jeanpierre, 2011-07-03 07:18
Messages (3)
msg139670 - (view) Author: Devin Jeanpierre (Devin Jeanpierre) * Date: 2011-07-03 07:07
It's probably best shown by example:

Have fun! This one looks hard.

Some notes: Exchanging g2() for iter([1]) makes this go away. Wrapping g2 inside a non-generator iterator does not make this go away. 

Removing the call to next(it) after it = g2() makes the problem go away, as does replacing those two lines with next(g2()).

The file used in that ideone paste is attached for your convenience.


Debugging is impractical for me with this bug in existence. It never stopped printing the traceback before I killed the process. (And let's forget about debug prints!)
msg139672 - (view) Author: Devin Jeanpierre (Devin Jeanpierre) * Date: 2011-07-03 07:18
Updated to be clearer / less full of mistakes that coincidentally work:
msg139695 - (view) Author: Roundup Robot (python-dev) Date: 2011-07-03 18:44
New changeset cc7ae81cfe91 by Benjamin Peterson in branch '3.2':
restore a generator's caller's exception state both on yield and (last) return

New changeset 33dca840938d by Benjamin Peterson in branch 'default':
merge 3.2 (#12475)
Date User Action Args
2011-07-03 18:44:33python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg139695

resolution: fixed
stage: resolved
2011-07-03 14:26:38r.david.murraysetnosy: + ncoghlan
2011-07-03 07:27:18georg.brandlsetassignee: pitrou

nosy: + pitrou
2011-07-03 07:18:25Devin Jeanpierresetfiles: +

messages: + msg139672
2011-07-03 07:17:04Devin Jeanpierresetfiles: -
2011-07-03 07:07:43Devin Jeanpierrecreate