GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||
GeezerVison is showing github.com — gh-103791: Make contextlib.suppress also act on exceptions within an ExceptionGroup by ambv · Pull Request #103792 · python/cpython Conversation
|
| match, rest = excinst.split(self._exceptions) | ||
| if rest is None: | ||
| return True | ||
| raise rest |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This isn't ideal as it makes the exception group's own traceback include the def __exit__(...) frame. For example:
File "/Volumes/RAMDisk/cpython/Lib/test/test_contextlib.py", line 1220, in test_exception_groups
with suppress(ValueError):
File "/Volumes/RAMDisk/cpython/Lib/contextlib.py", line 454, in __exit__
raise rest from excinst
File "/Volumes/RAMDisk/cpython/Lib/test/test_contextlib.py", line 1221, in test_exception_groups
raise eg_all()
in case of the newly added test.
This isn't a big problem because:
raise of the original group is still included in the traceback because we used .split() to create the new object.Ideally, we wouldn't need this. However, the API of __exit__ makes it impossible to replace the ExceptionGroup instance with another one, while ExceptionGroup itself makes its exceptions read-only.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Minor doc tweaks.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Co-authored-by: Irit Katriel <[email protected]>
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
(just testing out "request changes")
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
When you're done making the requested changes, leave the comment: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
OK, GitHub indeed doesn't disable auto-merge when changes are requested
* main: pythongh-87729: add LOAD_SUPER_ATTR instruction for faster super() (python#103497) pythongh-103791: Make contextlib.suppress also act on exceptions within an ExceptionGroup (python#103792)
| return | ||
| if issubclass(exctype, self._exceptions): | ||
| return True | ||
| if issubclass(exctype, ExceptionGroup): |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Was there a specific reason to handle ExceptionGroup but not BaseExceptionGroup?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I doubt it. Want to make a PR?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.