Debian Codegraph @

Include/internal/pycore_import.h

raw
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 #ifndef Py_BUILD_CORE
9 # error "this header requires Py_BUILD_CORE define"
10 #endif
11
12 #include "pycore_hashtable.h" // _Py_hashtable_t
13 #include "pycore_interp_structs.h" // _import_state
14
15 extern int _PyImport_IsInitialized(PyInterpreterState *);
16
17 // Export for 'pyexpat' shared extension
18 PyAPI_FUNC(int) _PyImport_SetModule(PyObject *name, PyObject *module);
19
20 extern int _PyImport_SetModuleString(const char *name, PyObject* module);
21
22 extern void _PyImport_AcquireLock(PyInterpreterState *interp);
23 extern void _PyImport_ReleaseLock(PyInterpreterState *interp);
24 extern void _PyImport_ReInitLock(PyInterpreterState *interp);
25
26 // This is used exclusively for the sys and builtins modules:
27 extern int _PyImport_FixupBuiltin(
28 PyThreadState *tstate,
29 PyObject *mod,
30 const char *name, /* UTF-8 encoded string */
31 PyObject *modules
32 );
33
34 #ifdef HAVE_DLOPEN
35 # include <dlfcn.h> // RTLD_NOW, RTLD_LAZY
36 # if HAVE_DECL_RTLD_NOW
37 # define _Py_DLOPEN_FLAGS RTLD_NOW
38 # else
39 # define _Py_DLOPEN_FLAGS RTLD_LAZY
40 # endif
41 # define DLOPENFLAGS_INIT .dlopenflags = _Py_DLOPEN_FLAGS,
42 #else
43 # define _Py_DLOPEN_FLAGS 0
44 # define DLOPENFLAGS_INIT
45 #endif
46
47 #define IMPORTS_INIT \
48 { \
49 DLOPENFLAGS_INIT \
50 .find_and_load = { \
51 .header = 1, \
52 }, \
53 }
54
55 extern void _PyImport_ClearCore(PyInterpreterState *interp);
56
57 extern Py_ssize_t _PyImport_GetNextModuleIndex(void);
58 extern const char * _PyImport_ResolveNameWithPackageContext(const char *name);
59 extern const char * _PyImport_SwapPackageContext(const char *newcontext);
60
61 extern int _PyImport_GetDLOpenFlags(PyInterpreterState *interp);
62 extern void _PyImport_SetDLOpenFlags(PyInterpreterState *interp, int new_val);
63
64 extern PyObject * _PyImport_InitModules(PyInterpreterState *interp);
65 extern PyObject * _PyImport_GetModules(PyInterpreterState *interp);
66 extern PyObject * _PyImport_GetModulesRef(PyInterpreterState *interp);
67 extern void _PyImport_ClearModules(PyInterpreterState *interp);
68
69 extern void _PyImport_ClearModulesByIndex(PyInterpreterState *interp);
70
71 extern int _PyImport_InitDefaultImportFunc(PyInterpreterState *interp);
72 extern int _PyImport_IsDefaultImportFunc(
73 PyInterpreterState *interp,
74 PyObject *func);
75
76 extern PyObject * _PyImport_GetImportlibLoader(
77 PyInterpreterState *interp,
78 const char *loader_name);
79 extern PyObject * _PyImport_GetImportlibExternalLoader(
80 PyInterpreterState *interp,
81 const char *loader_name);
82 extern PyObject * _PyImport_BlessMyLoader(
83 PyInterpreterState *interp,
84 PyObject *module_globals);
85 extern PyObject * _PyImport_ImportlibModuleRepr(
86 PyInterpreterState *interp,
87 PyObject *module);
88
89
90 extern PyStatus _PyImport_Init(void);
91 extern void _PyImport_Fini(void);
92 extern void _PyImport_Fini2(void);
93
94 extern PyStatus _PyImport_InitCore(
95 PyThreadState *tstate,
96 PyObject *sysmod,
97 int importlib);
98 extern PyStatus _PyImport_InitExternal(PyThreadState *tstate);
99 extern void _PyImport_FiniCore(PyInterpreterState *interp);
100 extern void _PyImport_FiniExternal(PyInterpreterState *interp);
101
102
103 extern PyObject* _PyImport_GetBuiltinModuleNames(void);
104
105 struct _module_alias {
106 const char *name; /* ASCII encoded string */
107 const char *orig; /* ASCII encoded string */
108 };
109
110 // Export these 3 symbols for test_ctypes
111 PyAPI_DATA(const struct _frozen*) _PyImport_FrozenBootstrap;
112 PyAPI_DATA(const struct _frozen*) _PyImport_FrozenStdlib;
113 PyAPI_DATA(const struct _frozen*) _PyImport_FrozenTest;
114
115 extern const struct _module_alias * _PyImport_FrozenAliases;
116
117 extern int _PyImport_CheckSubinterpIncompatibleExtensionAllowed(
118 const char *name);
119
120
121 // Export for '_testinternalcapi' shared extension
122 PyAPI_FUNC(int) _PyImport_ClearExtension(PyObject *name, PyObject *filename);
123
124 #ifdef Py_GIL_DISABLED
125 // Assuming that the GIL is enabled from a call to
126 // _PyEval_EnableGILTransient(), resolve the transient request depending on the
127 // state of the module argument:
128 // - If module is NULL or a PyModuleObject with md_gil == Py_MOD_GIL_NOT_USED,
129 // call _PyEval_DisableGIL().
130 // - Otherwise, call _PyEval_EnableGILPermanent(). If the GIL was not already
131 // enabled permanently, issue a warning referencing the module's name.
132 //
133 // This function may raise an exception.
134 extern int _PyImport_CheckGILForModule(PyObject *module, PyObject *module_name);
135 #endif
136
137 #ifdef __cplusplus
138 }
139 #endif
140 #endif /* !Py_INTERNAL_IMPORT_H */
141 #endif /* !Py_LIMITED_API */