##// END OF EJS Templates
Apply some small formatting fixes in ultratb
EtiennePelletier -
Show More
1 NO CONTENT: modified file
@@ -591,7 +591,7 b' class ListTB(TBTools):'
591 591 """
592 592
593 593 Colors = self.Colors
594 list = []
594 output_list = []
595 595 for ind, (filename, lineno, name, line) in enumerate(extracted_list):
596 596 normalCol, nameCol, fileCol, lineCol = (
597 597 # Emphasize the last entry
@@ -609,9 +609,9 b' class ListTB(TBTools):'
609 609 item += "\n"
610 610 if line:
611 611 item += f"{lineCol} {line.strip()}{normalCol}\n"
612 list.append(item)
612 output_list.append(item)
613 613
614 return list
614 return output_list
615 615
616 616 def _format_exception_only(self, etype, value):
617 617 """Format the exception part of a traceback.
@@ -628,11 +628,11 b' class ListTB(TBTools):'
628 628 """
629 629 have_filedata = False
630 630 Colors = self.Colors
631 list = []
631 output_list = []
632 632 stype = py3compat.cast_unicode(Colors.excName + etype.__name__ + Colors.Normal)
633 633 if value is None:
634 634 # Not sure if this can still happen in Python 2.6 and above
635 list.append(stype + '\n')
635 output_list.append(stype + "\n")
636 636 else:
637 637 if issubclass(etype, SyntaxError):
638 638 have_filedata = True
@@ -643,7 +643,7 b' class ListTB(TBTools):'
643 643 else:
644 644 lineno = "unknown"
645 645 textline = ""
646 list.append(
646 output_list.append(
647 647 "%s %s%s\n"
648 648 % (
649 649 Colors.normalEm,
@@ -663,31 +663,33 b' class ListTB(TBTools):'
663 663 i = 0
664 664 while i < len(textline) and textline[i].isspace():
665 665 i += 1
666 list.append('%s %s%s\n' % (Colors.line,
667 textline.strip(),
668 Colors.Normal))
666 output_list.append(
667 "%s %s%s\n" % (Colors.line, textline.strip(), Colors.Normal)
668 )
669 669 if value.offset is not None:
670 670 s = ' '
671 671 for c in textline[i:value.offset - 1]:
672 672 if c.isspace():
673 673 s += c
674 674 else:
675 s += ' '
676 list.append('%s%s^%s\n' % (Colors.caret, s,
677 Colors.Normal))
675 s += " "
676 output_list.append(
677 "%s%s^%s\n" % (Colors.caret, s, Colors.Normal)
678 )
678 679
679 680 try:
680 681 s = value.msg
681 682 except Exception:
682 683 s = self._some_str(value)
683 684 if s:
684 list.append('%s%s:%s %s\n' % (stype, Colors.excName,
685 Colors.Normal, s))
685 output_list.append(
686 "%s%s:%s %s\n" % (stype, Colors.excName, Colors.Normal, s)
687 )
686 688 else:
687 list.append('%s\n' % stype)
689 output_list.append("%s\n" % stype)
688 690
689 691 # PEP-678 notes
690 list.extend(f"{x}\n" for x in getattr(value, "__notes__", []))
692 output_list.extend(f"{x}\n" for x in getattr(value, "__notes__", []))
691 693
692 694 # sync with user hooks
693 695 if have_filedata:
@@ -695,7 +697,7 b' class ListTB(TBTools):'
695 697 if ipinst is not None:
696 698 ipinst.hooks.synchronize_with_editor(value.filename, value.lineno, 0)
697 699
698 return list
700 return output_list
699 701
700 702 def get_exception_only(self, etype, value):
701 703 """Only print the exception type and message, without a traceback.
@@ -1012,6 +1014,7 b' class VerboseTB(TBTools):'
1012 1014 etype, evalue = str, sys.exc_info()[:2]
1013 1015 etype_str, evalue_str = map(str, (etype, evalue))
1014 1016
1017 # PEP-678 notes
1015 1018 notes = getattr(evalue, "__notes__", [])
1016 1019 if not isinstance(notes, Sequence) or isinstance(notes, (str, bytes)):
1017 1020 notes = [_safe_string(notes, "__notes__", func=repr)]
General Comments 0
You need to be logged in to leave comments. Login now