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-105927: PyImport_AddModule() uses _PyWeakref_GET_REF()#106001

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
vstinner merged 1 commit intopython:mainfromvstinner:getref_add_module
Jun 22, 2023

Conversation

vstinner
Copy link
Member

@vstinnervstinner commentedJun 22, 2023
edited by bedevere-bot
Loading

It now raises an exception if sys.modules doesn't hold a strong reference to the module.

Elaborate the comment explaining why a weak reference is used to create a borrowed reference.

It now raises an exception if sys.modules doesn't hold a strongreference to the module.Elaborate the comment explaining why a weak reference is used tocreate a borrowed reference.
Py_DECREF(ref);
Py_XDECREF(mod);

if (mod == NULL && !PyErr_Occurred()) {

Choose a reason for hiding this comment

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

I am not sure that comparing mod with NULL after Py_XDECREF does not have an undefined behavior. AFAIK, you can do nothing with a pointer to released memory, not even compare it with NULL.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

See comments of my PR#105998: IMO most of this code is useless and can be removed.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@serhiy-storchakaserhiy-storchakaserhiy-storchaka left review comments

@brettcannonbrettcannonAwaiting requested review from brettcannon

@ericsnowcurrentlyericsnowcurrentlyAwaiting requested review from ericsnowcurrently

@ncoghlanncoghlanAwaiting requested review from ncoghlan

@warsawwarsawAwaiting requested review from warsaw

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

Successfully merging this pull request may close these issues.

3 participants
@vstinner@serhiy-storchaka@bedevere-bot

[8]ページ先頭

©2009-2025 Movatter.jp