[issue16596] Skip stack unwinding when "next", "until" and "return" pdb commands executed in generator context

Xavier de Gaye report at bugs.python.org
Thu Dec 6 20:44:21 CET 2012


Xavier de Gaye added the comment:

In the test named 'test_pdb_return_command_for_generator' in the patch, the
return command does not cause pdb to stop at the StopIteration debug event as
expected. Instead the following step command steps into the generator.

With the patch applied, in the following debugging session, pdb does not stop
after the 'next' command.  Pdb should stop to stay consistent with the way
'next' behaves in the same case on a plain function.

===   bar.py   ===
def g():
    yield 0

it = g()
while True:
    try:
        x = next(it)
        print(x)
    except StopIteration:
        break
==================
$ ./python -m pdb /tmp/bar.py
> /tmp/bar.py(1)<module>()
-> def g():
(Pdb) break g
Breakpoint 1 at /tmp/bar.py:1
(Pdb) continue
> /tmp/bar.py(2)g()
-> yield 0
(Pdb) next
0
The program finished and will be restarted
> /tmp/bar.py(1)<module>()
-> def g():
(Pdb)
==================

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16596>
_______________________________________


More information about the Python-bugs-list mailing list