Closed GoogleCodeExporter closed 9 years ago
Some more observations.
Interestingly, I'm seeing the same problem running the code not from ipm but
rather as a user module.
Have added some debug code:
def gen(o):
print "enter gen"
yield o
print "ret gen"
def d(o):
for i in gen(o):
print i
print "ret d"
After calling d(123), the screen output is:
enter gen
123
ret gen
So I never saw the calling function d() returning. It still looks like a crash.
E.
Original comment by zigli...@gmail.com
on 28 Jun 2010 at 12:58
Simpler case fails in ipm:
ipm> def gen(o):
yield o
ipm> for i in gen(4):
print i
4
ipm> a=4
Connection write error, type Ctrl+D to quit.
Connection read error, type Ctrl+D to quit.
Original comment by dwhall...@gmail.com
on 5 Aug 2010 at 3:12
Problem found!
The code at the very bottom of the VM's for() loop that was supposed to find a
B_LOOP block when a StopIteration exception occurs was not exiting its search
loop when the block was found.
Non-interactive mode didn't display this defect because when the StopIteration
exception was raised in the test code, there was only one loop structure around
the executing code. Whereas, in interactive mode, src/lib/ipm.py has a "while
1" loop around the read-eval-print loop that runs ipm. So in interactive mode,
the VM was finding the B_LOOP block of that outer while loop and using it,
which led to ipm and the VM completing code execution and exiting.
Original comment by dwhall...@gmail.com
on 7 Aug 2010 at 3:54
r566
- Removed code in RETURN_VALUE bytecode that tried to handle StopIteration
early.
- Fixed the StopIteration exception handler at the bottom of the VM bytecode
loop. The "break" statement was only breaking out of the innermost "while"
loop.
- Added an "assert" line to ipm to catch when a real StopIteration gets caught
by ipm's "while 1" loop.
All tests pass, including manual ipm tests in the comments above.
Original comment by dwhall...@gmail.com
on 7 Aug 2010 at 4:10
Excellent, I don't know much about the internals but I'm glad ipm behaves even
more like the non-interactive mode.
Original comment by zigli...@gmail.com
on 7 Aug 2010 at 8:36
Original issue reported on code.google.com by
dwhall...@gmail.com
on 27 Jun 2010 at 11:53