Make --showlocals work together with --tb=short
Enable showing local variables when asked to do so in the short traceback mode. Fixes #494
This commit is contained in:
@@ -785,9 +785,7 @@ class FormattedExcinfo:
|
||||
message = excinfo and excinfo.typename or ""
|
||||
path = self._makepath(entry.path)
|
||||
filelocrepr = ReprFileLocation(path, entry.lineno + 1, message)
|
||||
localsrepr = None
|
||||
if not short:
|
||||
localsrepr = self.repr_locals(entry.locals)
|
||||
localsrepr = self.repr_locals(entry.locals)
|
||||
return ReprEntry(lines, reprargs, localsrepr, filelocrepr, style)
|
||||
if excinfo:
|
||||
lines.extend(self.get_exconly(excinfo, indent=4))
|
||||
@@ -1044,6 +1042,8 @@ class ReprEntry(TerminalRepr):
|
||||
for line in self.lines:
|
||||
red = line.startswith("E ")
|
||||
tw.line(line, bold=True, red=red)
|
||||
if self.reprlocals:
|
||||
self.reprlocals.toterminal(tw, indent=" " * 8)
|
||||
return
|
||||
if self.reprfuncargs:
|
||||
self.reprfuncargs.toterminal(tw)
|
||||
@@ -1085,9 +1085,9 @@ class ReprLocals(TerminalRepr):
|
||||
def __init__(self, lines: Sequence[str]) -> None:
|
||||
self.lines = lines
|
||||
|
||||
def toterminal(self, tw) -> None:
|
||||
def toterminal(self, tw, indent="") -> None:
|
||||
for line in self.lines:
|
||||
tw.line(line)
|
||||
tw.line(indent + line)
|
||||
|
||||
|
||||
class ReprFuncArgs(TerminalRepr):
|
||||
|
||||
Reference in New Issue
Block a user