##// END OF EJS Templates
Fix case where some Exceptions have no traceback. (#14153)...
Matthias Bussonnier -
r28391:15554be2 merge
parent child Browse files
Show More
@@ -419,7 +419,12 b' class Pdb(OldPdb):'
419 rep = repr(exc)
419 rep = repr(exc)
420 if len(rep) > 80:
420 if len(rep) > 80:
421 rep = rep[:77] + "..."
421 rep = rep[:77] + "..."
422 self.message(f"{prompt} {ix:>3} {rep}")
422 indicator = (
423 " -"
424 if self._chained_exceptions[ix].__traceback__ is None
425 else f"{ix:>3}"
426 )
427 self.message(f"{prompt} {indicator} {rep}")
423 else:
428 else:
424 try:
429 try:
425 number = int(arg)
430 number = int(arg)
@@ -427,6 +432,12 b' class Pdb(OldPdb):'
427 self.error("Argument must be an integer")
432 self.error("Argument must be an integer")
428 return
433 return
429 if 0 <= number < len(self._chained_exceptions):
434 if 0 <= number < len(self._chained_exceptions):
435 if self._chained_exceptions[number].__traceback__ is None:
436 self.error(
437 "This exception does not have a traceback, cannot jump to it"
438 )
439 return
440
430 self._chained_exception_index = number
441 self._chained_exception_index = number
431 self.setup(None, self._chained_exceptions[number].__traceback__)
442 self.setup(None, self._chained_exceptions[number].__traceback__)
432 self.print_stack_entry(self.stack[self.curindex])
443 self.print_stack_entry(self.stack[self.curindex])
@@ -438,6 +449,8 b' class Pdb(OldPdb):'
438 if CHAIN_EXCEPTIONS:
449 if CHAIN_EXCEPTIONS:
439 # this context manager is part of interaction in 3.13
450 # this context manager is part of interaction in 3.13
440 _chained_exceptions, tb = self._get_tb_and_exceptions(tb_or_exc)
451 _chained_exceptions, tb = self._get_tb_and_exceptions(tb_or_exc)
452 if isinstance(tb_or_exc, BaseException):
453 assert tb is not None, "main exception must have a traceback"
441 with self._hold_exceptions(_chained_exceptions):
454 with self._hold_exceptions(_chained_exceptions):
442 OldPdb.interaction(self, frame, tb)
455 OldPdb.interaction(self, frame, tb)
443 else:
456 else:
General Comments 0
You need to be logged in to leave comments. Login now