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-113358: Fix rendering tracebacks with exceptions with a broken __getattr__ by perrinjerome · Pull Request #113359 · python/cpython Conversation
|
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| try: | ||
| notes = getattr(exc_value, '__notes__', None) | ||
| except Exception: | ||
| pass |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
We don't swallow exceptions like this. What is your use case for defining an exception with a broken __getattr__?
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 had much the same question on the issue. Python reporting bugs in user code does not seem like a python bug. OP needs to justify the python bug claim by quoting doc that says that user exceptions will by caught, or make this a feature request, with justification.
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.
Thank you for your feedback, I am sorry I did not explain enough. I have tried to add more context to the issue.
About not swallowing exceptions, I don't like it either (and I understand the negative feedback), maybe this patch should be adjusted to at least report that an exception occurred while getting the notes, by doing something like this instead ?
try: self.__notes__ = getattr(exc_value, '__notes__', None) except Exception as e: self.__notes__ = [ f'Ignored exception getting __notes__: {_safe_string(e, '__notes__', repr)}']
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.
Unfortunately we do swallow exceptions like this. _safe_string() set a bad precedence since 2823f03.
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 have updated the patch to include the "Ignored exception getting notes ..." in the notes as suggested above, from the discussion on the issue it seemed better to include information about the error in that case.
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]>
|
Thanks @perrinjerome for the PR, and @vsajip for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks @perrinjerome for the PR, and @vsajip for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…en __getattr__ (pythonGH-113359) (cherry picked from commit 04fabe2) Co-authored-by: Jérome Perrin <[email protected]> Co-authored-by: Irit Katriel <[email protected]>
|
Sorry, @perrinjerome and @vsajip, I could not cleanly backport this to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
GH-114105 is a backport of this pull request to the 3.12 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
… a broken __getattr__ (pythonGH-113359) (cherry picked from commit 04fabe2) Co-authored-by: Jérome Perrin <[email protected]> Co-authored-by: Irit Katriel <[email protected]>
|
GH-114109 is a backport of this pull request to the 3.11 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
… a broken __getattr__ (pythonGH-113359) (cherry picked from commit 04fabe2) Co-authored-by: Jérome Perrin <[email protected]> Co-authored-by: Irit Katriel <[email protected]>
… a broken __getattr__ (pythonGH-113359) (cherry picked from commit 04fabe2) Co-authored-by: Jérome Perrin <[email protected]> Co-authored-by: Irit Katriel <[email protected]>
|
GH-114118 is a backport of this pull request to the 3.11 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
GH-114118 is a backport of this pull request to the 3.11 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
GH-114118 is a backport of this pull request to the 3.11 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…en __getattr__ (pythonGH-113359) cherry picked from commit 04fabe2 Adjusted for 3.11, because exception printing also happens in C code. For simplicity, instead of including the repr of the exception that happened during __getattr__, this just prints that an error occured. Co-authored-by: Jérome Perrin <[email protected]> Co-authored-by: Irit Katriel <[email protected]>
…en __getattr__ (pythonGH-113359) cherry picked from commit 04fabe2 Adjusted for 3.11, because exception printing also happens in C code. For simplicity, instead of including the repr of the exception that happened during __getattr__, this just prints that an error occured. Co-authored-by: Jérome Perrin <[email protected]> Co-authored-by: Irit Katriel <[email protected]>
…en __getattr__ (pythonGH-113359) cherry picked from commit 04fabe2 Adjusted for 3.11, because exception printing also happens in C code. Co-authored-by: Jérome Perrin <[email protected]> Co-authored-by: Irit Katriel <[email protected]>
…en __getattr__ (pythonGH-113359) cherry picked from commit 04fabe2 Adjusted for 3.11, because exception printing also happens in C code. Co-authored-by: Jérome Perrin <[email protected]> Co-authored-by: Irit Katriel <[email protected]>
…en __getattr__ (pythonGH-113359) cherry picked from commit 04fabe2 Adjusted for 3.11, because exception printing also happens in C code. Co-authored-by: Jérome Perrin <[email protected]> Co-authored-by: Irit Katriel <[email protected]>
|
GH-114173 is a backport of this pull request to the 3.12 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…en __getattr__ (pythonGH-113359) cherry picked from commit 04fabe2 Adjusted for 3.12, because exception printing also happens in C code. Co-authored-by: Jérome Perrin <[email protected]> Co-authored-by: Irit Katriel <[email protected]>
… a broken __getattr__ (pythonGH-113359) (cherry picked from commit 04fabe2) Co-authored-by: Jérome Perrin <[email protected]> Co-authored-by: Irit Katriel <[email protected]>
… a broken __getattr__ (pythonGH-113359) (cherry picked from commit 04fabe2) Co-authored-by: Jérome Perrin <[email protected]> Co-authored-by: Irit Katriel <[email protected]>
…en __getattr__ (pythonGH-113359) Co-authored-by: Irit Katriel <[email protected]>
…en __getattr__ (pythonGH-113359) Co-authored-by: Irit Katriel <[email protected]>
…en __getattr__ (pythonGH-113359) Co-authored-by: Irit Katriel <[email protected]>
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.