@@ -517,7 +517,7 @@ def _validate_file_mtime(self):
517517
518518 # Called before loop, handles display expressions
519519 # Set up convenience variable containers
520- def preloop (self ):
520+ def _show_display (self ):
521521 displaying = self .displaying .get (self .curframe )
522522 if displaying :
523523 for expr , oldvalue in displaying .items ():
@@ -605,15 +605,13 @@ def interaction(self, frame, tb_or_exc):
605605 self .setup (frame , tb )
606606 # We should print the stack entry if and only if the user input
607607 # is expected, and we should print it right before the user input.
608- # If self.cmdqueue is not empty, we append a "w 0" command to the
609- # queue, which is equivalent to print_stack_entry
610- if self .cmdqueue :
611- self .cmdqueue .append ('w 0' )
612- else :
613- self .print_stack_entry (self .stack [self .curindex ])
608+ # We achieve this by appending _pdbcmd_print_frame_status to the
609+ # command queue. If cmdqueue is not exausted, the user input is
610+ # not expected and we will not print the stack entry.
611+ self .cmdqueue .append ('_pdbcmd_print_frame_status' )
614612 self ._cmdloop ()
615- # If "w 0" is not used, pop it out
616- if self .cmdqueue and self .cmdqueue [- 1 ] == 'w 0 ' :
613+ # If _pdbcmd_print_frame_status is not used, pop it out
614+ if self .cmdqueue and self .cmdqueue [- 1 ] == '_pdbcmd_print_frame_status ' :
617615 self .cmdqueue .pop ()
618616 self .forget ()
619617
@@ -846,6 +844,10 @@ def onecmd(self, line):
846844 """
847845 if not self .commands_defining :
848846 self ._validate_file_mtime ()
847+ if line .startswith ('_pdbcmd' ):
848+ command , arg , line = self .parseline (line )
849+ if hasattr (self , command ):
850+ return getattr (self , command )(arg )
849851 return cmd .Cmd .onecmd (self , line )
850852 else :
851853 return self .handle_command_def (line )
@@ -982,6 +984,12 @@ def completedefault(self, text, line, begidx, endidx):
982984 state += 1
983985 return matches
984986
987+ # Pdb meta commands, only intended to be used internally by pdb
988+
989+ def _pdbcmd_print_frame_status (self , arg ):
990+ self .print_stack_trace (0 )
991+ self ._show_display ()
992+
985993 # Command definitions, called by cmdloop()
986994 # The argument is the remaining string on the command line
987995 # Return true to exit from the command loop
0 commit comments