summaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Include/moduleobject.h
diff options
context:
space:
mode:
authorAlexSm <[email protected]>2024-02-16 11:51:30 +0100
committerGitHub <[email protected]>2024-02-16 11:51:30 +0100
commit506ecaee93b52cc12c2e2f97c3d42e3ca2a7f59e (patch)
treed096fb9eb988fbb0ca1ba970041773207ce3aa70 /contrib/tools/python3/src/Include/moduleobject.h
parent4749b9e5d260714490997e6f5ee1ee8c1c8fc46c (diff)
parentf200f72c9d7a89c1018e3dc6b46c49fe2ecf84fb (diff)
Merge pull request #1940 from dcherednik/importlib
Library import 14
Diffstat (limited to 'contrib/tools/python3/src/Include/moduleobject.h')
-rw-r--r--contrib/tools/python3/src/Include/moduleobject.h30
1 files changed, 27 insertions, 3 deletions
diff --git a/contrib/tools/python3/src/Include/moduleobject.h b/contrib/tools/python3/src/Include/moduleobject.h
index 75abd2cf2b9..354d133e45e 100644
--- a/contrib/tools/python3/src/Include/moduleobject.h
+++ b/contrib/tools/python3/src/Include/moduleobject.h
@@ -9,8 +9,8 @@ extern "C" {
PyAPI_DATA(PyTypeObject) PyModule_Type;
-#define PyModule_Check(op) PyObject_TypeCheck(op, &PyModule_Type)
-#define PyModule_CheckExact(op) Py_IS_TYPE(op, &PyModule_Type)
+#define PyModule_Check(op) PyObject_TypeCheck((op), &PyModule_Type)
+#define PyModule_CheckExact(op) Py_IS_TYPE((op), &PyModule_Type)
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
PyAPI_FUNC(PyObject *) PyModule_NewObject(
@@ -43,8 +43,22 @@ PyAPI_DATA(PyTypeObject) PyModuleDef_Type;
typedef struct PyModuleDef_Base {
PyObject_HEAD
+ /* The function used to re-initialize the module.
+ This is only set for legacy (single-phase init) extension modules
+ and only used for those that support multiple initializations
+ (m_size >= 0).
+ It is set by _PyImport_LoadDynamicModuleWithSpec()
+ and _imp.create_builtin(). */
PyObject* (*m_init)(void);
+ /* The module's index into its interpreter's modules_by_index cache.
+ This is set for all extension modules but only used for legacy ones.
+ (See PyInterpreterState.modules_by_index for more info.)
+ It is set by PyModuleDef_Init(). */
Py_ssize_t m_index;
+ /* A copy of the module's __dict__ after the first time it was loaded.
+ This is only set/used for legacy modules that do not support
+ multiple initializations.
+ It is set by _PyImport_FixupExtensionObject(). */
PyObject* m_copy;
} PyModuleDef_Base;
@@ -64,13 +78,23 @@ struct PyModuleDef_Slot {
#define Py_mod_create 1
#define Py_mod_exec 2
+#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030c0000
+# define Py_mod_multiple_interpreters 3
+#endif
#ifndef Py_LIMITED_API
-#define _Py_mod_LAST_SLOT 2
+#define _Py_mod_LAST_SLOT 3
#endif
#endif /* New in 3.5 */
+/* for Py_mod_multiple_interpreters: */
+#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030c0000
+# define Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED ((void *)0)
+# define Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED ((void *)1)
+# define Py_MOD_PER_INTERPRETER_GIL_SUPPORTED ((void *)2)
+#endif
+
struct PyModuleDef {
PyModuleDef_Base m_base;
const char* m_name;