33import fnmatch
44import sys
55import os
6- from inspect import CO_GENERATOR
6+ from inspect import CO_GENERATOR , CO_COROUTINE
77
88__all__ = ["BdbQuit" , "Bdb" , "Breakpoint" ]
99
@@ -127,7 +127,7 @@ def dispatch_call(self, frame, arg):
127127 # No need to trace this function
128128 return # None
129129 # Ignore call events in generator except when stepping.
130- if self .stopframe and frame .f_code .co_flags & CO_GENERATOR :
130+ if self .stopframe and frame .f_code .co_flags & ( CO_GENERATOR | CO_COROUTINE ) :
131131 return self .trace_dispatch
132132 self .user_call (frame , arg )
133133 if self .quitting : raise BdbQuit
@@ -142,7 +142,7 @@ def dispatch_return(self, frame, arg):
142142 """
143143 if self .stop_here (frame ) or frame == self .returnframe :
144144 # Ignore return events in generator except when stepping.
145- if self .stopframe and frame .f_code .co_flags & CO_GENERATOR :
145+ if self .stopframe and frame .f_code .co_flags & ( CO_GENERATOR | CO_COROUTINE ) :
146146 return self .trace_dispatch
147147 try :
148148 self .frame_returning = frame
@@ -166,7 +166,7 @@ def dispatch_exception(self, frame, arg):
166166 # When stepping with next/until/return in a generator frame, skip
167167 # the internal StopIteration exception (with no traceback)
168168 # triggered by a subiterator run with the 'yield from' statement.
169- if not (frame .f_code .co_flags & CO_GENERATOR
169+ if not (frame .f_code .co_flags & ( CO_GENERATOR | CO_COROUTINE )
170170 and arg [0 ] is StopIteration and arg [2 ] is None ):
171171 self .user_exception (frame , arg )
172172 if self .quitting : raise BdbQuit
@@ -175,7 +175,7 @@ def dispatch_exception(self, frame, arg):
175175 # next/until command at the last statement in the generator before the
176176 # exception.
177177 elif (self .stopframe and frame is not self .stopframe
178- and self .stopframe .f_code .co_flags & CO_GENERATOR
178+ and self .stopframe .f_code .co_flags & ( CO_GENERATOR | CO_COROUTINE )
179179 and arg [0 ] in (StopIteration , GeneratorExit )):
180180 self .user_exception (frame , arg )
181181 if self .quitting : raise BdbQuit
@@ -309,7 +309,7 @@ def set_next(self, frame):
309309
310310 def set_return (self , frame ):
311311 """Stop when returning from the given frame."""
312- if frame .f_code .co_flags & CO_GENERATOR :
312+ if frame .f_code .co_flags & ( CO_GENERATOR | CO_COROUTINE ) :
313313 self ._set_stopinfo (frame , None , - 1 )
314314 else :
315315 self ._set_stopinfo (frame .f_back , frame )
0 commit comments