diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2024-05-29 21:54:47 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-29 21:54:47 (GMT) |
commit | af57832e634720a797a54973a85d15ac3e13cf60 (patch) | |
tree | 65dfe86dc4bfaafeda2a6bb9cc22b01d0d4a6f74 /Modules | |
parent | a7aa7c41ebfce5bf537c939c8dfc0605adcfabd8 (diff) | |
download | cpython-af57832e634720a797a54973a85d15ac3e13cf60.zip cpython-af57832e634720a797a54973a85d15ac3e13cf60.tar.gz cpython-af57832e634720a797a54973a85d15ac3e13cf60.tar.bz2 |
[3.13] gh-117398: Add multiphase support to _datetime (gh-119694)
This is an unrevert of d58ebf0 (gh-119636), which was reverted by 9216a53 (gh-119639) due to problems which have been resolved.
This is minimal support for multiphase init. Subinterpreters are not supported yet. That will be addressed in a later change.
(cherry picked from commit 3e8b609)
Co-authored-by: Erlend E. Aasland erlend@python.org
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_datetimemodule.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c index 8339c98..54383ca 100644 --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -7048,30 +7048,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); } /* --------------------------------------------------------------------------- |