From 5ee41577c78726484282285f223d6b05057eb431 Mon Sep 17 00:00:00 2001 From: zhaoyu Date: Wed, 5 Jan 2022 19:58:15 +0800 Subject: [PATCH 1/2] bpo-1635741:Port _datetime extension module to multiphase initialization (PEP 489) https://bugs.python.org/issue1635741 --- Modules/_datetimemodule.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c index fda8401b84cd15..0cc3ca41ee9cc6 100644 --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -6694,27 +6694,27 @@ _datetime_exec(PyObject *module) return 0; } +static struct PyModuleDef_Slot _datetime_slots[] = { + {Py_mod_exec, _datetime_exec}, + {0, NULL} +}; + +PyDoc_STRVAR(module_doc, +"Fast implementation of the datetime type."); + static struct PyModuleDef datetimemodule = { PyModuleDef_HEAD_INIT, .m_name = "_datetime", - .m_doc = "Fast implementation of the datetime type.", - .m_size = -1, + .m_doc = module_doc, + .m_size = 0, .m_methods = module_methods, + .m_slots = _datetime_slots, }; PyMODINIT_FUNC PyInit__datetime(void) { - PyObject *mod = PyModule_Create(&datetimemodule); - if (mod == NULL) - return NULL; - - if (_datetime_exec(mod) < 0) { - Py_DECREF(mod); - return NULL; - } - - return mod; + return PyModuleDef_Init(&datetimemodule); } /* --------------------------------------------------------------------------- From 0254dd92dc16f29a55a5567ca4410285cd1b2529 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Tue, 11 Jan 2022 01:10:12 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Core and Builtins/2022-01-11-01-10-11.bpo-1635741.7Haspf.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2022-01-11-01-10-11.bpo-1635741.7Haspf.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-01-11-01-10-11.bpo-1635741.7Haspf.rst b/Misc/NEWS.d/next/Core and Builtins/2022-01-11-01-10-11.bpo-1635741.7Haspf.rst new file mode 100644 index 00000000000000..08b13c6fdabb7e --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2022-01-11-01-10-11.bpo-1635741.7Haspf.rst @@ -0,0 +1 @@ +Port _datetime extension module to multiphase initialization(:pep:`489`). \ No newline at end of file