Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 01b63ec

Browse filesBrowse files
authored
bpo-35134: Add Include/cpython/import.h header file (GH-14213)
* Add Include/cpython/import.h and Include/internal/pycore_import.h header files. * Move _PyImport_ReInitLock() to the internal C API. Don't export the symbol anymore.
1 parent 54cf2e0 commit 01b63ec
Copy full SHA for 01b63ec

File tree

Expand file treeCollapse file tree

7 files changed

+86
-52
lines changed
Filter options
Expand file treeCollapse file tree

7 files changed

+86
-52
lines changed

‎Include/cpython/import.h

Copy file name to clipboard
+57Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#ifndef Py_CPYTHON_IMPORT_H
2+
# error "this header file must not be included directly"
3+
#endif
4+
5+
#ifdef __cplusplus
6+
extern "C" {
7+
#endif
8+
9+
PyMODINIT_FUNC PyInit__imp(void);
10+
11+
PyAPI_FUNC(int) _PyImport_IsInitialized(PyInterpreterState *);
12+
13+
PyAPI_FUNC(PyObject *) _PyImport_GetModuleId(struct _Py_Identifier *name);
14+
PyAPI_FUNC(PyObject *) _PyImport_AddModuleObject(PyObject *name,
15+
PyObject *modules);
16+
PyAPI_FUNC(int) _PyImport_SetModule(PyObject *name, PyObject *module);
17+
PyAPI_FUNC(int) _PyImport_SetModuleString(const char *name, PyObject* module);
18+
19+
PyAPI_FUNC(void) _PyImport_AcquireLock(void);
20+
PyAPI_FUNC(int) _PyImport_ReleaseLock(void);
21+
22+
PyAPI_FUNC(PyObject *) _PyImport_FindBuiltin(
23+
const char *name, /* UTF-8 encoded string */
24+
PyObject *modules
25+
);
26+
PyAPI_FUNC(PyObject *) _PyImport_FindExtensionObject(PyObject *, PyObject *);
27+
PyAPI_FUNC(PyObject *) _PyImport_FindExtensionObjectEx(PyObject *, PyObject *,
28+
PyObject *);
29+
PyAPI_FUNC(int) _PyImport_FixupBuiltin(
30+
PyObject *mod,
31+
const char *name, /* UTF-8 encoded string */
32+
PyObject *modules
33+
);
34+
PyAPI_FUNC(int) _PyImport_FixupExtensionObject(PyObject*, PyObject *,
35+
PyObject *, PyObject *);
36+
37+
struct _inittab {
38+
const char *name; /* ASCII encoded string */
39+
PyObject* (*initfunc)(void);
40+
};
41+
PyAPI_DATA(struct _inittab *) PyImport_Inittab;
42+
PyAPI_FUNC(int) PyImport_ExtendInittab(struct _inittab *newtab);
43+
44+
struct _frozen {
45+
const char *name; /* ASCII encoded string */
46+
const unsigned char *code;
47+
int size;
48+
};
49+
50+
/* Embedding apps may change this pointer to point to their favorite
51+
collection of frozen modules: */
52+
53+
PyAPI_DATA(const struct _frozen *) PyImport_FrozenModules;
54+
55+
#ifdef __cplusplus
56+
}
57+
#endif

‎Include/import.h

Copy file name to clipboardExpand all lines: Include/import.h
+3-51Lines changed: 3 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/* Module definition and import interface */
32

43
#ifndef Py_IMPORT_H
@@ -7,9 +6,6 @@
76
extern "C" {
87
#endif
98

10-
#ifndef Py_LIMITED_API
11-
PyMODINIT_FUNC PyInit__imp(void);
12-
#endif /* !Py_LIMITED_API */
139
PyAPI_FUNC(long) PyImport_GetMagicNumber(void);
1410
PyAPI_FUNC(const char *) PyImport_GetMagicTag(void);
1511
PyAPI_FUNC(PyObject *) PyImport_ExecCodeModule(
@@ -39,14 +35,6 @@ PyAPI_FUNC(PyObject *) PyImport_GetModuleDict(void);
3935
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03070000
4036
PyAPI_FUNC(PyObject *) PyImport_GetModule(PyObject *name);
4137
#endif
42-
#ifndef Py_LIMITED_API
43-
PyAPI_FUNC(int) _PyImport_IsInitialized(PyInterpreterState *);
44-
PyAPI_FUNC(PyObject *) _PyImport_GetModuleId(struct _Py_Identifier *name);
45-
PyAPI_FUNC(PyObject *) _PyImport_AddModuleObject(PyObject *name,
46-
PyObject *modules);
47-
PyAPI_FUNC(int) _PyImport_SetModule(PyObject *name, PyObject *module);
48-
PyAPI_FUNC(int) _PyImport_SetModuleString(const char *name, PyObject* module);
49-
#endif
5038
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
5139
PyAPI_FUNC(PyObject *) PyImport_AddModuleObject(
5240
PyObject *name
@@ -94,35 +82,6 @@ PyAPI_FUNC(int) PyImport_ImportFrozenModule(
9482
const char *name /* UTF-8 encoded string */
9583
);
9684

97-
#ifndef Py_LIMITED_API
98-
PyAPI_FUNC(void) _PyImport_AcquireLock(void);
99-
PyAPI_FUNC(int) _PyImport_ReleaseLock(void);
100-
101-
PyAPI_FUNC(void) _PyImport_ReInitLock(void);
102-
103-
PyAPI_FUNC(PyObject *) _PyImport_FindBuiltin(
104-
const char *name, /* UTF-8 encoded string */
105-
PyObject *modules
106-
);
107-
PyAPI_FUNC(PyObject *) _PyImport_FindExtensionObject(PyObject *, PyObject *);
108-
PyAPI_FUNC(PyObject *) _PyImport_FindExtensionObjectEx(PyObject *, PyObject *,
109-
PyObject *);
110-
PyAPI_FUNC(int) _PyImport_FixupBuiltin(
111-
PyObject *mod,
112-
const char *name, /* UTF-8 encoded string */
113-
PyObject *modules
114-
);
115-
PyAPI_FUNC(int) _PyImport_FixupExtensionObject(PyObject*, PyObject *,
116-
PyObject *, PyObject *);
117-
118-
struct _inittab {
119-
const char *name; /* ASCII encoded string */
120-
PyObject* (*initfunc)(void);
121-
};
122-
PyAPI_DATA(struct _inittab *) PyImport_Inittab;
123-
PyAPI_FUNC(int) PyImport_ExtendInittab(struct _inittab *newtab);
124-
#endif /* Py_LIMITED_API */
125-
12685
PyAPI_DATA(PyTypeObject) PyNullImporter_Type;
12786

12887
PyAPI_FUNC(int) PyImport_AppendInittab(
@@ -131,16 +90,9 @@ PyAPI_FUNC(int) PyImport_AppendInittab(
13190
);
13291

13392
#ifndef Py_LIMITED_API
134-
struct _frozen {
135-
const char *name; /* ASCII encoded string */
136-
const unsigned char *code;
137-
int size;
138-
};
139-
140-
/* Embedding apps may change this pointer to point to their favorite
141-
collection of frozen modules: */
142-
143-
PyAPI_DATA(const struct _frozen *) PyImport_FrozenModules;
93+
# define Py_CPYTHON_IMPORT_H
94+
# include "cpython/import.h"
95+
# undef Py_CPYTHON_IMPORT_H
14496
#endif
14597

14698
#ifdef __cplusplus

‎Include/internal/pycore_import.h

Copy file name to clipboard
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#ifndef Py_LIMITED_API
2+
#ifndef Py_INTERNAL_IMPORT_H
3+
#define Py_INTERNAL_IMPORT_H
4+
#ifdef __cplusplus
5+
extern "C" {
6+
#endif
7+
8+
extern void _PyImport_ReInitLock(void);
9+
10+
#ifdef __cplusplus
11+
}
12+
#endif
13+
#endif /* !Py_INTERNAL_IMPORT_H */
14+
#endif /* !Py_LIMITED_API */

‎Makefile.pre.in

Copy file name to clipboardExpand all lines: Makefile.pre.in
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,7 @@ PYTHON_HEADERS= \
10541054
$(srcdir)/Include/cpython/abstract.h \
10551055
$(srcdir)/Include/cpython/dictobject.h \
10561056
$(srcdir)/Include/cpython/fileobject.h \
1057+
$(srcdir)/Include/cpython/import.h \
10571058
$(srcdir)/Include/cpython/initconfig.h \
10581059
$(srcdir)/Include/cpython/interpreteridobject.h \
10591060
$(srcdir)/Include/cpython/object.h \
@@ -1077,6 +1078,7 @@ PYTHON_HEADERS= \
10771078
$(srcdir)/Include/internal/pycore_getopt.h \
10781079
$(srcdir)/Include/internal/pycore_gil.h \
10791080
$(srcdir)/Include/internal/pycore_hamt.h \
1081+
$(srcdir)/Include/internal/pycore_import.h \
10801082
$(srcdir)/Include/internal/pycore_initconfig.h \
10811083
$(srcdir)/Include/internal/pycore_object.h \
10821084
$(srcdir)/Include/internal/pycore_pathconfig.h \

‎Modules/posixmodule.c

Copy file name to clipboardExpand all lines: Modules/posixmodule.c
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#endif
3737

3838
#include "pycore_ceval.h" /* _PyEval_ReInitThreads() */
39+
#include "pycore_import.h" /* _PyImport_ReInitLock() */
3940
#include "pycore_pystate.h" /* _PyRuntime */
4041
#include "pythread.h"
4142
#include "structmember.h"

‎PCbuild/pythoncore.vcxproj

Copy file name to clipboardExpand all lines: PCbuild/pythoncore.vcxproj
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@
129129
<ClInclude Include="..\Include\cpython\abstract.h" />
130130
<ClInclude Include="..\Include\cpython\dictobject.h" />
131131
<ClInclude Include="..\Include\cpython\fileobject.h" />
132+
<ClInclude Include="..\Include\cpython\import.h" />
132133
<ClInclude Include="..\Include\cpython\initconfig.h" />
133134
<ClInclude Include="..\Include\cpython\object.h" />
134135
<ClInclude Include="..\Include\cpython\objimpl.h" />
@@ -158,14 +159,15 @@
158159
<ClInclude Include="..\Include\import.h" />
159160
<ClInclude Include="..\Include\internal\pycore_accu.h" />
160161
<ClInclude Include="..\Include\internal\pycore_atomic.h" />
161-
<ClInclude Include="..\Include\internal\pycore_code.h" />
162162
<ClInclude Include="..\Include\internal\pycore_ceval.h" />
163+
<ClInclude Include="..\Include\internal\pycore_code.h" />
163164
<ClInclude Include="..\Include\internal\pycore_condvar.h" />
164165
<ClInclude Include="..\Include\internal\pycore_context.h" />
165166
<ClInclude Include="..\Include\internal\pycore_fileutils.h" />
166167
<ClInclude Include="..\Include\internal\pycore_getopt.h" />
167168
<ClInclude Include="..\Include\internal\pycore_gil.h" />
168169
<ClInclude Include="..\Include\internal\pycore_hamt.h" />
170+
<ClInclude Include="..\Include\internal\pycore_import.h" />
169171
<ClInclude Include="..\Include\internal\pycore_initconfig.h" />
170172
<ClInclude Include="..\Include\internal\pycore_object.h" />
171173
<ClInclude Include="..\Include\internal\pycore_pathconfig.h" />

‎PCbuild/pythoncore.vcxproj.filters

Copy file name to clipboardExpand all lines: PCbuild/pythoncore.vcxproj.filters
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@
9090
<ClInclude Include="..\Include\cpython\fileobject.h">
9191
<Filter>Include</Filter>
9292
</ClInclude>
93+
<ClInclude Include="..\Include\cpython\import.h">
94+
<Filter>Include</Filter>
95+
</ClInclude>
9396
<ClInclude Include="..\Include\cpython\initconfig.h">
9497
<Filter>Include</Filter>
9598
</ClInclude>
@@ -201,6 +204,9 @@
201204
<ClInclude Include="..\Include\internal\pycore_hamt.h">
202205
<Filter>Include</Filter>
203206
</ClInclude>
207+
<ClInclude Include="..\Include\internal\pycore_import.h">
208+
<Filter>Include</Filter>
209+
</ClInclude>
204210
<ClInclude Include="..\Include\internal\pycore_initconfig.h">
205211
<Filter>Include</Filter>
206212
</ClInclude>

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.