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
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Port _abc extension module to multiphase initialization (:pep:`489`).

Modules/_abc.c

Lines changed: 18 additions & 9 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy