-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
gh-98458: unittest: bugfix for infinite loop while handling chained exceptions that contain cycles #98459
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
…ed exception in TestResult._clean_tracebacks()
Most changes to Python require a NEWS entry. Please add it using the blurb_it web app or the blurb command-line tool. |
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.
Can you add a test for this? It would be good to also test the more exotic case of a loop of mutually-chained exceptions, such as:
try:
raise ValueError(1)
except ValueError as e:
try:
raise KeyError(2) from e
except KeyError as e2:
raise e from e2
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.
Please add a test for this and address @iritkatriel's review.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
…cks. The "seen" set follows the approach used in the TracebackException class (thank you @iritkatriel for pointing it out)
I have made the requested changes; please review again |
Thanks for making the requested changes! @kumaraditya303: please review the changes made to this pull request. |
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.
Looks good, I'd add another test.
…olds a self-loop in its __cause__ and __context__ attributes
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.
LGTM.
@gpshead - as a maintainer of unittest, do you want to backport this?
GH-99995 is a backport of this pull request to the 3.11 branch. |
GH-99996 is a backport of this pull request to the 3.10 branch. |
…ined exceptions that contain cycles (pythonGH-98459) * Bugfix addressing infinite loop while handling self-referencing chained exception in TestResult._clean_tracebacks() * Bugfix extended to properly handle exception cycles in _clean_tracebacks. The "seen" set follows the approach used in the TracebackException class (thank you @iritkatriel for pointing it out) * adds a test for a single chained exception that holds a self-loop in its __cause__ and __context__ attributes (cherry picked from commit 72ec518) Co-authored-by: AlexTate <[email protected]>
…ined exceptions that contain cycles (pythonGH-98459) * Bugfix addressing infinite loop while handling self-referencing chained exception in TestResult._clean_tracebacks() * Bugfix extended to properly handle exception cycles in _clean_tracebacks. The "seen" set follows the approach used in the TracebackException class (thank you @iritkatriel for pointing it out) * adds a test for a single chained exception that holds a self-loop in its __cause__ and __context__ attributes (cherry picked from commit 72ec518) Co-authored-by: AlexTate <[email protected]>
…xceptions that contain cycles (GH-98459) * Bugfix addressing infinite loop while handling self-referencing chained exception in TestResult._clean_tracebacks() * Bugfix extended to properly handle exception cycles in _clean_tracebacks. The "seen" set follows the approach used in the TracebackException class (thank you @iritkatriel for pointing it out) * adds a test for a single chained exception that holds a self-loop in its __cause__ and __context__ attributes (cherry picked from commit 72ec518) Co-authored-by: AlexTate <[email protected]>
…xceptions that contain cycles (GH-98459) * Bugfix addressing infinite loop while handling self-referencing chained exception in TestResult._clean_tracebacks() * Bugfix extended to properly handle exception cycles in _clean_tracebacks. The "seen" set follows the approach used in the TracebackException class (thank you @iritkatriel for pointing it out) * adds a test for a single chained exception that holds a self-loop in its __cause__ and __context__ attributes (cherry picked from commit 72ec518) Co-authored-by: AlexTate <[email protected]>
Closes #98458