8000 gh-106320: Remove private _PyImport C API functions by vstinner · Pull Request #106383 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-106320: Remove private _PyImport C API functions #106383

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 3, 2023
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
20 changes: 0 additions & 20 deletions Include/cpython/import.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,6 @@

PyMODINIT_FUNC PyInit__imp(void);

PyAPI_FUNC(int) _PyImport_IsInitialized(PyInterpreterState *);

PyAPI_FUNC(PyObject *) _PyImport_GetModuleId(_Py_Identifier *name);
PyAPI_FUNC(int) _PyImport_SetModule(PyObject *name, PyObject *module);
PyAPI_FUNC(int) _PyImport_SetModuleString(const char *name, PyObject* module);

PyAPI_FUNC(void) _PyImport_AcquireLock(PyI 8000 nterpreterState *interp);
PyAPI_FUNC(int) _PyImport_ReleaseLock(PyInterpreterState *interp);

PyAPI_FUNC(int) _PyImport_FixupBuiltin(
PyObject *mod,
const char *name, /* UTF-8 encoded string */
PyObject *modules
);
PyAPI_FUNC(int) _PyImport_FixupExtensionObject(PyObject*, PyObject *,
PyObject *, PyObject *);

struct _inittab {
const char *name; /* ASCII encoded string */
PyObject* (*initfunc)(void);
Expand All @@ -41,6 +24,3 @@ struct _frozen {
collection of frozen modules: */

PyAPI_DATA(const struct _frozen *) PyImport_FrozenModules;

PyAPI_DATA(PyObject *) _PyImport_GetModuleAttr(PyObject *, PyObject *);
PyAPI_DATA(PyObject *) _PyImport_GetModuleAttrString(const char *, const char *);
20 changes: 20 additions & 0 deletions Include/internal/pycore_import.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@ extern "C" {

#include "pycore_time.h" // _PyTime_t

extern int _PyImport_IsInitialized(PyInterpreterState *);

PyAPI_FUNC(PyObject *) _PyImport_GetModuleId(_Py_Identifier *name);
PyAPI_FUNC(int) _PyImport_SetModule(PyObject *name, PyObject *module);
PyAPI_FUNC(int) _PyImport_SetModuleString(const char *name, PyObject* module);

extern void _PyImport_AcquireLock(PyInterpreterState *interp);
extern int _PyImport_ReleaseLock(PyInterpreterState *interp);

extern int _PyImport_FixupBuiltin(
PyObject *mod,
const char *name, /* UTF-8 encoded string */
PyObject *modules
);
extern int _PyImport_FixupExtensionObject(PyObject*, PyObject *,
PyObject *, PyObject *);

PyAPI_DATA(PyObject *) _PyImport_GetModuleAttr(PyObject *, PyObject *);
PyAPI_DATA(PyObject *) _PyImport_GetModuleAttrString(const char *, const char *);


struct _import_runtime_state {
/* The builtin modules (defined in config.c). */
Expand Down
5 changes: 5 additions & 0 deletions Modules/_elementtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@
*--------------------------------------------------------------------
*/

#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif

#include "Python.h"
#include "pycore_import.h" // _PyImport_GetModuleAttrString()
#include "structmember.h" // PyMemberDef
#include "expat.h"
#include "pyexpat.h"
Expand Down
1 change: 1 addition & 0 deletions Modules/_sqlite/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "blob.h"
#include "prepare_protocol.h"
#include "util.h"
#include "pycore_import.h" // _PyImport_GetModuleAttrString()
#include "pycore_weakref.h" // _PyWeakref_IS_DEAD()

#include <stdbool.h>
Expand Down
6 changes: 6 additions & 0 deletions Modules/_sqlite/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
* 3. This notice may not be removed or altered from any source distribution.
*/

#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif

#include "connection.h"
#include "statement.h"
#include "cursor.h"
Expand All @@ -29,6 +33,8 @@
#include "row.h"
#include "blob.h"

#include "pycore_import.h" // _PyImport_GetModuleAttrString()

#if SQLITE_VERSION_NUMBER < 3015002
#error "SQLite 3.15.2 or higher required"
#endif
Expand Down
10 changes: 8 additions & 2 deletions Modules/_testcapimodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1267,9 +1267,15 @@ test_pep3118_obsolete_write_locks(PyObject* self, PyObject *Py_UNUSED(ignored))
if (ret != -1 || match == 0)
goto error;

PyObject *mod_io = PyImport_ImportModule("_io");
if (mod_io == NULL) {
return NULL;
}

/* bytesiobuf_getbuffer() */
PyTypeObject *type = (PyTypeObject *)_PyImport_GetModuleAttrString(
"_io", "_BytesIOBuffer");
PyTypeObject *type = (PyTypeObject *)PyObject_GetAttrString(
mod_io, "_BytesIOBuffer");
Py_DECREF(mod_io);
if (type == NULL) {
return NULL;
}
Expand Down
1 change: 1 addition & 0 deletions Modules/cjkcodecs/cjkcodecs.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include "Python.h"
#include "multibytecodec.h"
#include "pycore_import.h" // _PyImport_GetModuleAttrString()


/* a unicode "undefined" code point */
Expand Down
5 changes: 5 additions & 0 deletions Modules/pyexpat.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif

#include "Python.h"
#include "pycore_import.h" // _PyImport_SetModule()
#include <ctype.h>

#include "structmember.h" // PyMemberDef
Expand Down
0