Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-1635741: Port _datetime extension module to multiphase initialization (PEP 489) #30522

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Port _datetime extension module to multiphase initialization(:pep:`489`).
24 changes: 12 additions & 12 deletions Modules/_datetimemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/* ---------------------------------------------------------------------------
Expand Down