-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-111388: Add show_group
to traceback.format_exception_only
#111390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
for l in formatted | ||
] | ||
else: | ||
yield _format_final_exc_line(stype, self._str) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this fix need to be backported to 3.12/311?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, because 3.12 does not have show_group
/ _depth
at all:
Lines 865 to 892 in 307ca78
def format_exception_only(self): | |
"""Format the exception part of the traceback. | |
The return value is a generator of strings, each ending in a newline. | |
Generator yields the exception message. | |
For :exc:`SyntaxError` exceptions, it | |
also yields (before the exception message) | |
several lines that (when printed) | |
display detailed information about where the syntax error occurred. | |
Following the message, generator also yields | |
all the exception's ``__notes__``. | |
""" | |
if self.exc_type is None: | |
yield _format_final_exc_line(None, self._str) | |
return | |
stype = self.exc_type.__qualname__ | |
smod = self.exc_type.__module__ | |
if smod not in ("__main__", "builtins"): | |
if not isinstance(smod, str): | |
smod = "<unknown>" | |
stype = smod + '.' + stype | |
if not issubclass(self.exc_type, SyntaxError): | |
yield _format_final_exc_line(stype, self._str) | |
else: | |
yield from self._format_syntax_error(stype) |
And without it, the result is identical with and without this fix.
This is the first step to #104150
show_group
param totraceback.format_exception_only
function #111388📚 Documentation preview 📚: https://cpython-previews--111390.org.readthedocs.build/