Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/AnonR/smanonr..../lib64/python3....
File: traceback.py
self.exc_traceback = exc_traceback
[500] Fix | Delete
self.__cause__ = cause
[501] Fix | Delete
self.__context__ = context
[502] Fix | Delete
self.__suppress_context__ = \
[503] Fix | Delete
exc_value.__suppress_context__ if exc_value else False
[504] Fix | Delete
# TODO: locals.
[505] Fix | Delete
self.stack = StackSummary.extract(
[506] Fix | Delete
walk_tb(exc_traceback), limit=limit, lookup_lines=lookup_lines,
[507] Fix | Delete
capture_locals=capture_locals)
[508] Fix | Delete
self.exc_type = exc_type
[509] Fix | Delete
# Capture now to permit freeing resources: only complication is in the
[510] Fix | Delete
# unofficial API _format_final_exc_line
[511] Fix | Delete
self._str = _some_str(exc_value)
[512] Fix | Delete
if exc_type and issubclass(exc_type, SyntaxError):
[513] Fix | Delete
# Handle SyntaxError's specially
[514] Fix | Delete
self.filename = exc_value.filename
[515] Fix | Delete
self.lineno = str(exc_value.lineno)
[516] Fix | Delete
self.text = exc_value.text
[517] Fix | Delete
self.offset = exc_value.offset
[518] Fix | Delete
self.msg = exc_value.msg
[519] Fix | Delete
if lookup_lines:
[520] Fix | Delete
self._load_lines()
[521] Fix | Delete
[522] Fix | Delete
@classmethod
[523] Fix | Delete
def from_exception(cls, exc, *args, **kwargs):
[524] Fix | Delete
"""Create a TracebackException from an exception."""
[525] Fix | Delete
return cls(type(exc), exc, exc.__traceback__, *args, **kwargs)
[526] Fix | Delete
[527] Fix | Delete
def _load_lines(self):
[528] Fix | Delete
"""Private API. force all lines in the stack to be loaded."""
[529] Fix | Delete
for frame in self.stack:
[530] Fix | Delete
frame.line
[531] Fix | Delete
if self.__context__:
[532] Fix | Delete
self.__context__._load_lines()
[533] Fix | Delete
if self.__cause__:
[534] Fix | Delete
self.__cause__._load_lines()
[535] Fix | Delete
[536] Fix | Delete
def __eq__(self, other):
[537] Fix | Delete
return self.__dict__ == other.__dict__
[538] Fix | Delete
[539] Fix | Delete
def __str__(self):
[540] Fix | Delete
return self._str
[541] Fix | Delete
[542] Fix | Delete
def format_exception_only(self):
[543] Fix | Delete
"""Format the exception part of the traceback.
[544] Fix | Delete
[545] Fix | Delete
The return value is a generator of strings, each ending in a newline.
[546] Fix | Delete
[547] Fix | Delete
Normally, the generator emits a single string; however, for
[548] Fix | Delete
SyntaxError exceptions, it emites several lines that (when
[549] Fix | Delete
printed) display detailed information about where the syntax
[550] Fix | Delete
error occurred.
[551] Fix | Delete
[552] Fix | Delete
The message indicating which exception occurred is always the last
[553] Fix | Delete
string in the output.
[554] Fix | Delete
"""
[555] Fix | Delete
if self.exc_type is None:
[556] Fix | Delete
yield _format_final_exc_line(None, self._str)
[557] Fix | Delete
return
[558] Fix | Delete
[559] Fix | Delete
stype = self.exc_type.__qualname__
[560] Fix | Delete
smod = self.exc_type.__module__
[561] Fix | Delete
if smod not in ("__main__", "builtins"):
[562] Fix | Delete
stype = smod + '.' + stype
[563] Fix | Delete
[564] Fix | Delete
if not issubclass(self.exc_type, SyntaxError):
[565] Fix | Delete
yield _format_final_exc_line(stype, self._str)
[566] Fix | Delete
return
[567] Fix | Delete
[568] Fix | Delete
# It was a syntax error; show exactly where the problem was found.
[569] Fix | Delete
filename = self.filename or "<string>"
[570] Fix | Delete
lineno = str(self.lineno) or '?'
[571] Fix | Delete
yield ' File "{}", line {}\n'.format(filename, lineno)
[572] Fix | Delete
[573] Fix | Delete
badline = self.text
[574] Fix | Delete
offset = self.offset
[575] Fix | Delete
if badline is not None:
[576] Fix | Delete
yield ' {}\n'.format(badline.strip())
[577] Fix | Delete
if offset is not None:
[578] Fix | Delete
caretspace = badline.rstrip('\n')
[579] Fix | Delete
offset = min(len(caretspace), offset) - 1
[580] Fix | Delete
caretspace = caretspace[:offset].lstrip()
[581] Fix | Delete
# non-space whitespace (likes tabs) must be kept for alignment
[582] Fix | Delete
caretspace = ((c.isspace() and c or ' ') for c in caretspace)
[583] Fix | Delete
yield ' {}^\n'.format(''.join(caretspace))
[584] Fix | Delete
msg = self.msg or "<no detail available>"
[585] Fix | Delete
yield "{}: {}\n".format(stype, msg)
[586] Fix | Delete
[587] Fix | Delete
def format(self, *, chain=True):
[588] Fix | Delete
"""Format the exception.
[589] Fix | Delete
[590] Fix | Delete
If chain is not *True*, *__cause__* and *__context__* will not be formatted.
[591] Fix | Delete
[592] Fix | Delete
The return value is a generator of strings, each ending in a newline and
[593] Fix | Delete
some containing internal newlines. `print_exception` is a wrapper around
[594] Fix | Delete
this method which just prints the lines to a file.
[595] Fix | Delete
[596] Fix | Delete
The message indicating which exception occurred is always the last
[597] Fix | Delete
string in the output.
[598] Fix | Delete
"""
[599] Fix | Delete
if chain:
[600] Fix | Delete
if self.__cause__ is not None:
[601] Fix | Delete
yield from self.__cause__.format(chain=chain)
[602] Fix | Delete
yield _cause_message
[603] Fix | Delete
elif (self.__context__ is not None and
[604] Fix | Delete
not self.__suppress_context__):
[605] Fix | Delete
yield from self.__context__.format(chain=chain)
[606] Fix | Delete
yield _context_message
[607] Fix | Delete
if self.exc_traceback is not None:
[608] Fix | Delete
yield 'Traceback (most recent call last):\n'
[609] Fix | Delete
yield from self.stack.format()
[610] Fix | Delete
yield from self.format_exception_only()
[611] Fix | Delete
[612] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function