mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
[3.10] bpo-45307: Restore private C API function _PyImport_FindExtensionObject() (GH-28594)
py2exe and PyOxidizer rely on this API. It will be removed in Python 3.11. Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
This commit is contained in:
parent
8f9d398b46
commit
ec4e2ec241
3 changed files with 22 additions and 0 deletions
|
@ -556,6 +556,23 @@ import_find_extension(PyThreadState *tstate, PyObject *name,
|
|||
return mod;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
_PyImport_FindExtensionObject(PyObject *name, PyObject *filename)
|
||||
{
|
||||
PyThreadState *tstate = _PyThreadState_GET();
|
||||
PyObject *mod = import_find_extension(tstate, name, filename);
|
||||
if (mod) {
|
||||
PyObject *ref = PyWeakref_NewRef(mod, NULL);
|
||||
Py_DECREF(mod);
|
||||
if (ref == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
mod = PyWeakref_GetObject(ref);
|
||||
Py_DECREF(ref);
|
||||
}
|
||||
return mod; /* borrowed reference */
|
||||
}
|
||||
|
||||
|
||||
/* Get the module object corresponding to a module name.
|
||||
First check the modules dictionary if there's one there,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue