We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c38da1e commit cef28f1Copy full SHA for cef28f1
Python/import.c
@@ -372,16 +372,7 @@ PyImport_AddModuleObject(PyObject *name)
372
if (!mod) {
373
return NULL;
374
}
375
-
376
- // gh-86160: PyImport_AddModuleObject() returns a borrowed reference
377
- PyObject *ref = PyWeakref_NewRef(mod, NULL);
378
- Py_DECREF(mod);
379
- if (ref == NULL) {
380
- return NULL;
381
- }
382
383
- mod = PyWeakref_GetObject(ref);
384
- Py_DECREF(ref);
+ Py_DECREF(mod); // sys.modules holds a strong reference
385
return mod; /* borrowed reference */
386
387
0 commit comments