gh-95754: Better AttributeError on partially initialised module#112577
Merged
hauntsaninja merged 7 commits intopython:mainfrom Dec 21, 2023
Merged
gh-95754: Better AttributeError on partially initialised module#112577hauntsaninja merged 7 commits intopython:mainfrom
hauntsaninja merged 7 commits intopython:mainfrom
Conversation
| if (suppress != 1) { | ||
| if (_PyModuleSpec_IsInitializing(spec)) { | ||
| PyErr_Format(PyExc_AttributeError, | ||
| origin = PyObject_GetAttr(spec, &_Py_ID(origin)); |
Member
There was a problem hiding this comment.
PyObject_GetAttr() can set not only AttributeError. If it sets a different error, it should not be overridden by AttributeError.
I suggest to use PyObject_GetOptionalAttr().
Member
There was a problem hiding this comment.
Why not chain the original error to a new exception (raise from)?
Member
There was a problem hiding this comment.
Or maybe this is a use case for adding a note to the original exception and letting it propagate on (if we don't want to change the type of the exception being raised).
Contributor
Author
|
Thank you for the reviews! |
Member
|
I fixed some errors, please resolve conflicts. |
Member
|
Would be great to mention this nice quality-of-life improvement with an example in What's New, similar to: |
ryan-duve
pushed a commit
to ryan-duve/cpython
that referenced
this pull request
Dec 26, 2023
…python#112577) Co-authored-by: Serhiy Storchaka <[email protected]>
kulikjak
pushed a commit
to kulikjak/cpython
that referenced
this pull request
Jan 22, 2024
…python#112577) Co-authored-by: Serhiy Storchaka <[email protected]>
aisk
pushed a commit
to aisk/cpython
that referenced
this pull request
Feb 11, 2024
…python#112577) Co-authored-by: Serhiy Storchaka <[email protected]>
Glyphack
pushed a commit
to Glyphack/cpython
that referenced
this pull request
Sep 2, 2024
…python#112577) Co-authored-by: Serhiy Storchaka <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Following in the footsteps of: