Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Include/cpython/import.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ PyAPI_FUNC(int) _PyImport_SetModuleString(const char *name, PyObject* module);
PyAPI_FUNC(void) _PyImport_AcquireLock(void);
PyAPI_FUNC(int) _PyImport_ReleaseLock(void);

/* Obsolete since 3.5, will be removed in 3.11. */
Py_DEPRECATED(3.10) PyAPI_FUNC(PyObject *) _PyImport_FindExtensionObject(PyObject *, PyObject *);

PyAPI_FUNC(int) _PyImport_FixupBuiltin(
PyObject *mod,
const char *name, /* UTF-8 encoded string */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Restore the private C API function :func:`_PyImport_FindExtensionObject`. It
will be removed in Python 3.11.
17 changes: 17 additions & 0 deletions Python/import.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down