##// END OF EJS Templates
Fix built-in and standard library pdb (πŸ™ˆ) so they are interruptible from Jupyter.
Itamar Turner-Trauring -
Show More
@@ -290,7 +290,7 b' class Pdb(OldPdb):'
290 try:
290 try:
291 OldPdb.interaction(self, frame, traceback)
291 OldPdb.interaction(self, frame, traceback)
292 except KeyboardInterrupt:
292 except KeyboardInterrupt:
293 self.stdout.write('\n' + self.shell.get_exception_only())
293 raise
294
294
295 def new_do_up(self, arg):
295 def new_do_up(self, arg):
296 OldPdb.do_up(self, arg)
296 OldPdb.do_up(self, arg)
@@ -627,6 +627,19 b' class Pdb(OldPdb):'
627
627
628 do_w = do_where
628 do_w = do_where
629
629
630 def _cmdloop(self):
631 # Variant that doesn't catch KeyboardInterrupts.
632 while True:
633 try:
634 # keyboard interrupts allow for an easy way to cancel
635 # the current command, so allow them during interactive input
636 self.allow_kbdint = True
637 self.cmdloop()
638 self.allow_kbdint = False
639 break
640 except KeyboardInterrupt:
641 raise
642
630
643
631 def set_trace(frame=None):
644 def set_trace(frame=None):
632 """
645 """
@@ -635,3 +648,10 b' def set_trace(frame=None):'
635 If frame is not specified, debugging starts from caller's frame.
648 If frame is not specified, debugging starts from caller's frame.
636 """
649 """
637 Pdb().set_trace(frame or sys._getframe().f_back)
650 Pdb().set_trace(frame or sys._getframe().f_back)
651
652
653 # Override built-in Pdb, since that version doesn't allow interrupting:
654 import pdb
655 pdb.set_trace = set_trace
656 pdb.Pdb = Pdb
657 del pdb
General Comments 0
You need to be logged in to leave comments. Login now