@@ -2647,12 +2647,12 @@ def set_trace(*, header=None, commands=None):
26472647 just before debugging begins. *commands* is an optional list of
26482648 pdb commands to run when the debugger starts.
26492649 """
2650- # Check if we're already in a pdb session by examining the call stack
2650+ # gh-138641: Check if we're already in a pdb session.
26512651 frame = sys ._getframe ()
26522652 while frame :
2653- if frame .f_code .co_name == 'interaction' and frame . f_code . co_filename . endswith ( 'pdb.py' ):
2654- # We're already in a pdb session, just print a message and return
2655- print ("*** Nested breakpoint calls are not supported. "
2653+ if ( frame .f_code .co_name == 'interaction'
2654+ and frame . f_code . co_filename . endswith ( ' pdb.py' )):
2655+ print ("Nested breakpoint calls are not supported. "
26562656 "Already running in the debugger." , file = sys .stderr )
26572657 return
26582658 frame = frame .f_back
@@ -2672,12 +2672,13 @@ async def set_trace_async(*, header=None, commands=None):
26722672 if they enter the debugger with this function. Otherwise it's the same
26732673 as set_trace().
26742674 """
2675- # Check if we're already in a pdb session by examining the call stack
2675+ # gh-138641: Check if we're already in a pdb session.
26762676 frame = sys ._getframe ()
26772677 while frame :
2678- if frame .f_code .co_name == 'interaction' and frame .f_code .co_filename .endswith ('pdb.py' ):
2678+ if (frame .f_code .co_name == 'interaction' and
2679+ frame .f_code .co_filename .endswith ('pdb.py' )):
26792680 # We're already in a pdb session, just print a message and return
2680- print ("*** Nested breakpoint calls are not supported. "
2681+ print ("Nested breakpoint calls are not supported. "
26812682 "Already running in the debugger." , file = sys .stderr )
26822683 return
26832684 frame = frame .f_back
0 commit comments