8000 [3.9] bpo-43048: RecursionError traceback RecursionError bugfix for cpy3.9 (GH-24460) by vlad17 · Pull Request #24460 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[3.9] bpo-43048: RecursionError traceback RecursionError bugfix for cpy3.9 (GH-24460) #24460

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

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
don't print context if you have (possibly truncated) cause
  • Loading branch information
vlad17 committed Feb 8, 2021
commit 041fcfbe3a72bc4f0893f4c6bc2836cbe8b5e9a0
9 changes: 6 additions & 3 deletions Lib/traceback.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ def __init__(self, exc_type, exc_value, exc_traceback, *, limit=None,
_seen.add(id(exc_value))
# Gracefully handle (the way Python 2.4 and earlier did) the case of
# being called with no type or value (None, None, None).

self.__suppress_context__ = False
self._truncated = False
if (exc_value and exc_value.__cause__ is not None
and id(exc_value.__cause__) not in _seen):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If recursion into constructing cause exceeded the recursion limit then surely the call to construct context will too. Why do we need to try blocks?

Expand All @@ -495,6 +495,9 @@ def __init__(self, exc_type, exc_value, exc_traceback, *, limit=None,
# so we must truncate.
self._truncated = True
cause = None
# Suppress the context during printing, so that even when
# a cause is truncated we don't print the context.
self.__suppress_context__ = True
else:
cause = None
if (exc_value and exc_value.__context__ is not None
Expand All @@ -515,8 +518,8 @@ def __init__(self, exc_type, exc_value, exc_traceback, *, limit=None,
context = None
self.__cause__ = cause
self.__context__ = context
self.__suppress_context__ = \
exc_value.__suppress_context__ if exc_value else False
self.__suppress_context__ = self.__suppress_context__ or (
exc_value.__suppress_context__ if exc_value else False)
# TODO: locals.
self.stack = StackSummary.extract(
walk_tb(exc_traceback), limit=limit, lookup_lines=lookup_lines,
Expand Down
0