diff options
author | Hai Shi <shihai1992@gmail.com> | 2020-02-17 13:50:35 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-17 13:50:35 (GMT) |
commit | 4c1b6a6f4fc46add0097efb3026cf3f0c89f88a2 (patch) | |
tree | 2f964a6e1ad16ff2bc7662f83b0f7f8ed09136fc | |
parent | 7d7956833cc37a9d42807cbfeb7dcc041970f579 (diff) | |
download | cpython-4c1b6a6f4fc46add0097efb3026cf3f0c89f88a2.zip cpython-4c1b6a6f4fc46add0097efb3026cf3f0c89f88a2.tar.gz cpython-4c1b6a6f4fc46add0097efb3026cf3f0c89f88a2.tar.bz2 |
bpo-1635741: Port _abc extension to multiphase initialization (PEP 489) (GH-18030)
-rw-r--r-- | Misc/NEWS.d/next/Core and Builtins/2020-01-16-12-00-04.bpo-1635741.fuqoBG.rst | 1 | ||||
-rw-r--r-- | Modules/_abc.c | 27 |
2 files changed, 19 insertions, 9 deletions
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-01-16-12-00-04.bpo-1635741.fuqoBG.rst b/Misc/NEWS.d/next/Core and Builtins/2020-01-16-12-00-04.bpo-1635741.fuqoBG.rst new file mode 100644 index 0000000..4dd37a6 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2020-01-16-12-00-04.bpo-1635741.fuqoBG.rst @@ -0,0 +1 @@ +Port _abc extension module to multiphase initialization (:pep:`489`). diff --git a/Modules/_abc.c b/Modules/_abc.c index e21fe78..c991295 100644 --- a/Modules/_abc.c +++ b/Modules/_abc.c @@ -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); } |