Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-95754: Better AttributeError on partially initialised module#112577

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
hauntsaninja merged 7 commits intopython:mainfromhauntsaninja:gh95754
Dec 21, 2023

Conversation

hauntsaninja
Copy link
Contributor

@hauntsaninjahauntsaninja commentedDec 1, 2023
edited
Loading

hugovk and yilei reacted with hooray emoji
@@ -841,11 +841,22 @@ _Py_module_getattro_impl(PyModuleObject *m, PyObject *name, int suppress)
}
if (suppress != 1) {
if (_PyModuleSpec_IsInitializing(spec)) {
PyErr_Format(PyExc_AttributeError,
origin = PyObject_GetAttr(spec, &_Py_ID(origin));

Choose a reason for 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 usePyObject_GetOptionalAttr().

Copy link
Member

Choose a reason for 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)?

Copy link
Member

Choose a reason for 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).

@hauntsaninja
Copy link
ContributorAuthor

Thank you for the reviews!

@serhiy-storchaka
Copy link
Member

I fixed some errors, please resolve conflicts.

Copy link
Member

@serhiy-storchakaserhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM.

@hugovk
Copy link
Member

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

ryan-duve pushed a commit to ryan-duve/cpython that referenced this pull requestDec 26, 2023
kulikjak pushed a commit to kulikjak/cpython that referenced this pull requestJan 22, 2024
aisk pushed a commit to aisk/cpython that referenced this pull requestFeb 11, 2024
Glyphack pushed a commit to Glyphack/cpython that referenced this pull requestSep 2, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@iritkatrieliritkatrieliritkatriel left review comments

@serhiy-storchakaserhiy-storchakaserhiy-storchaka approved these changes

@brettcannonbrettcannonAwaiting requested review from brettcannonbrettcannon is a code owner

@ericsnowcurrentlyericsnowcurrentlyAwaiting requested review from ericsnowcurrentlyericsnowcurrently is a code owner

@ncoghlanncoghlanAwaiting requested review from ncoghlanncoghlan is a code owner

@warsawwarsawAwaiting requested review from warsawwarsaw is a code owner

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@hauntsaninja@serhiy-storchaka@hugovk@iritkatriel

[8]ページ先頭

©2009-2025 Movatter.jp