Issue1385

classification
Title: generator.throw uncaught on new generator doesn't stop the generator
Type: Severity: normal
Components: Core Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: pjenvey
Priority: normal Keywords:

Created on 2009-06-22.06:36:04 by pjenvey, last changed 2010-04-13.02:18:05 by pjenvey.

Messages
msg4851 (view) Author: Philip Jenvey (pjenvey) Date: 2009-06-22.06:36:03
Jython 2.5.0+ (trunk:6489M, Jun 21 2009, 16:33:51) 
[Java HotSpot(TM) 64-Bit Server VM (Apple Inc.)] on java1.6.0_07
Type "help", "copyright", "credits" or "license" for more information.
>>> genexp = (i for i in range(2))
>>> genexp.throw(Exception)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
Exception
>>> genexp.gi_frame
<frame object at 0x1>
>>> genexp.next()
0

Python 2.5.4 (r254:67916, Apr 15 2009, 13:13:35) 
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> genexp = (i for i in range(2))
>>> genexp.throw(Exception)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 1, in <genexpr>
Exception
>>> genexp.gi_frame
>>> genexp.next()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
StopIteration

Works as expected if the generator was already started (the stack trace 
is also improved)

Jython 2.5.0+ (trunk:6489M, Jun 21 2009, 16:33:51) 
[Java HotSpot(TM) 64-Bit Server VM (Apple Inc.)] on java1.6.0_07
Type "help", "copyright", "credits" or "license" for more information.
>>> genexp = (i for i in range(5))
>>> genexp.next()
0
>>> genexp.throw(Exception)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 1, in <genexpr>
Exception
>>> genexp.gi_frame
>>> genexp.next()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
StopIteration
msg5688 (view) Author: Philip Jenvey (pjenvey) Date: 2010-04-13.02:18:04
fixed in r7024. The initial exception traceback still differs from CPython but that's a small implementation detail
History
Date User Action Args
2010-04-13 02:18:05pjenveysetstatus: open -> closed
resolution: fixed
messages: + msg5688
2009-06-22 06:36:04pjenveycreate