Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4c1b6a6

Browse files
authored
bpo-1635741: Port _abc extension to multiphase initialization (PEP 489) (GH-18030)
1 parent 7d79568 commit 4c1b6a6

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Port _abc extension module to multiphase initialization (:pep:`489`).

Modules/_abc.c

+18-9
Original file line numberDiff line numberDiff line change
@@ -807,26 +807,35 @@ static struct PyMethodDef module_functions[] = {
807807
{NULL, NULL} /* sentinel */
808808
};
809809

810+
static int
811+
_abc_exec(PyObject *module)
812+
{
813+
if (PyType_Ready(&_abc_data_type) < 0) {
814+
return -1;
815+
}
816+
_abc_data_type.tp_doc = abc_data_doc;
817+
return 0;
818+
}
819+
820+
static PyModuleDef_Slot _abc_slots[] = {
821+
{Py_mod_exec, _abc_exec},
822+
{0, NULL}
823+
};
824+
810825
static struct PyModuleDef _abcmodule = {
811826
PyModuleDef_HEAD_INIT,
812827
"_abc",
813828
_abc__doc__,
814-
-1,
829+
0,
815830
module_functions,
816-
NULL,
831+
_abc_slots,
817832
NULL,
818833
NULL,
819834
NULL
820835
};
821836

822-
823837
PyMODINIT_FUNC
824838
PyInit__abc(void)
825839
{
826-
if (PyType_Ready(&_abc_data_type) < 0) {
827-
return NULL;
828-
}
829-
_abc_data_type.tp_doc = abc_data_doc;
830-
831-
return PyModule_Create(&_abcmodule);
840+
return PyModuleDef_Init(&_abcmodule);
832841
}

0 commit comments

Comments
 (0)