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