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-95754: Better AttributeError on partially initialised module by hauntsaninja · Pull Request #112577 · python/cpython Conversation
|
| if (suppress != 1) { | ||
| if (_PyModuleSpec_IsInitializing(spec)) { | ||
| PyErr_Format(PyExc_AttributeError, | ||
| origin = PyObject_GetAttr(spec, &_Py_ID(origin)); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
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().
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.
Why not chain the original error to a new exception (raise from)?
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.
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).
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.
|
Thank you for the reviews! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I fixed some errors, please resolve conflicts. |
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 a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Would be great to mention this nice quality-of-life improvement with an example in What's New, similar to: https://docs.python.org/3/whatsnew/3.12.html#improved-error-messages |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…python#112577) Co-authored-by: Serhiy Storchaka <[email protected]>
…python#112577) Co-authored-by: Serhiy Storchaka <[email protected]>
…python#112577) Co-authored-by: Serhiy Storchaka <[email protected]>
…python#112577) Co-authored-by: Serhiy Storchaka <[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.