Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.4k
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
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()) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Uh oh!
There was an error while loading.Please reload this page.
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.