bpo-1635741: Port _abc extension to multiphase initialization (PEP 489) (GH-18030)

This commit is contained in:
Hai Shi 2020-02-17 21:50:35 +08:00 committed by GitHub
parent 7d7956833c
commit 4c1b6a6f4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 9 deletions

View File

@ -0,0 +1 @@
Port _abc extension module to multiphase initialization (:pep:`489`).

View File

@ -807,26 +807,35 @@ static struct PyMethodDef module_functions[] = {
{NULL, NULL} /* sentinel */
};
static int
_abc_exec(PyObject *module)
{
if (PyType_Ready(&_abc_data_type) < 0) {
return -1;
}
_abc_data_type.tp_doc = abc_data_doc;
return 0;
}
static PyModuleDef_Slot _abc_slots[] = {
{Py_mod_exec, _abc_exec},
{0, NULL}
};
static struct PyModuleDef _abcmodule = {
PyModuleDef_HEAD_INIT,
"_abc",
_abc__doc__,
-1,
0,
module_functions,
NULL,
_abc_slots,
NULL,
NULL,
NULL
};
PyMODINIT_FUNC
PyInit__abc(void)
{
if (PyType_Ready(&_abc_data_type) < 0) {
return NULL;
}
_abc_data_type.tp_doc = abc_data_doc;
return PyModule_Create(&_abcmodule);
return PyModuleDef_Init(&_abcmodule);
}