summaryrefslogtreecommitdiffstats
path: root/Lib/pdb.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@dropbox.com>2013-11-21 19:30:06 (GMT)
committerGuido van Rossum <guido@dropbox.com>2013-11-21 19:30:06 (GMT)
commit8820c239f778093ad432cf4dce6b607c6d1bf281 (patch)
tree907d2210e79264552f26371c4765e8319c9071b1 /Lib/pdb.py
parent9c55a58a1d7f664e7d236ef690d17409841632c4 (diff)
downloadcpython-8820c239f778093ad432cf4dce6b607c6d1bf281.zip
cpython-8820c239f778093ad432cf4dce6b607c6d1bf281.tar.gz
cpython-8820c239f778093ad432cf4dce6b607c6d1bf281.tar.bz2
Better behavior when stepping over yield[from]. Fixes issue 16596. By Xavier de Gaye.
Diffstat (limited to 'Lib/pdb.py')
-rwxr-xr-xLib/pdb.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/Lib/pdb.py b/Lib/pdb.py
index 2268d30..dd7ceb8 100755
--- a/Lib/pdb.py
+++ b/Lib/pdb.py
@@ -297,8 +297,16 @@ class Pdb(bdb.Bdb, cmd.Cmd):
return
exc_type, exc_value, exc_traceback = exc_info
frame.f_locals['__exception__'] = exc_type, exc_value
- self.message(traceback.format_exception_only(exc_type,
- exc_value)[-1].strip())
+
+ # An 'Internal StopIteration' exception is an exception debug event
+ # issued by the interpreter when handling a subgenerator run with
+ # 'yield from' or a generator controled by a for loop. No exception has
+ # actually occured in this case. The debugger uses this debug event to
+ # stop when the debuggee is returning from such generators.
+ prefix = 'Internal ' if (not exc_traceback
+ and exc_type is StopIteration) else ''
+ self.message('%s%s' % (prefix,
+ traceback.format_exception_only(exc_type, exc_value)[-1].strip()))
self.interaction(frame, exc_traceback)
# General interaction function