aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2024-05-28 00:36:32 +0200
committerGitHub <noreply@github.com>2024-05-27 16:36:32 -0600
commitd58ebf073c755c2f0f6e4ef2296b48a4c75e5f1c (patch)
tree837745c0e498bea3de1386fcbc1db44e7b5f68db /Modules
parent[3.13] gh-119584: Fix test_import Failed Assertion (gh-119623) (gh-119633) (diff)
downloadcpython-d58ebf073c755c2f0f6e4ef2296b48a4c75e5f1c.tar.gz
cpython-d58ebf073c755c2f0f6e4ef2296b48a4c75e5f1c.tar.bz2
cpython-d58ebf073c755c2f0f6e4ef2296b48a4c75e5f1c.zip
[3.13] gh-117398: Add multiphase support to _datetime (gh-119373) (gh-119636)
This is minimal support. Subinterpreters are not supported yet. That will be addressed in a later change. (cherry picked from commit 3e8b60905e97a4fe89bb24180063732214368938) Co-authored-by: Erlend E. Aasland <erlend@python.org> Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_datetimemodule.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c
index 8164715a66f..3ff8a2c6091 100644
--- a/Modules/_datetimemodule.c
+++ b/Modules/_datetimemodule.c
@@ -6970,30 +6970,26 @@ error:
}
#undef DATETIME_ADD_MACRO
-static struct PyModuleDef datetimemodule = {
+static PyModuleDef_Slot module_slots[] = {
+ {Py_mod_exec, _datetime_exec},
+ {Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},
+ {Py_mod_gil, Py_MOD_GIL_NOT_USED},
+ {0, NULL},
+};
+
+static PyModuleDef datetimemodule = {
.m_base = PyModuleDef_HEAD_INIT,
.m_name = "_datetime",
.m_doc = "Fast implementation of the datetime type.",
- .m_size = -1,
+ .m_size = 0,
.m_methods = module_methods,
+ .m_slots = module_slots,
};
PyMODINIT_FUNC
PyInit__datetime(void)
{
- PyObject *mod = PyModule_Create(&datetimemodule);
- if (mod == NULL)
- return NULL;
-#ifdef Py_GIL_DISABLED
- PyUnstable_Module_SetGIL(mod, Py_MOD_GIL_NOT_USED);
-#endif
-
- if (_datetime_exec(mod) < 0) {
- Py_DECREF(mod);
- return NULL;
- }
-
- return mod;
+ return PyModuleDef_Init(&datetimemodule);
}
/* ---------------------------------------------------------------------------