mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
bpo-40024: Update C extension modules to use PyModule_AddType() (GH-19119)
Update _asyncio, _bz2, _csv, _curses, _datetime, _io, _operator, _pickle, _queue, blake2, multibytecodec and overlapped C extension modules to use PyModule_AddType().
This commit is contained in:
parent
15e5024d04
commit
37fcbb65d4
12 changed files with 66 additions and 133 deletions
|
@ -2059,14 +2059,12 @@ static struct PyModuleDef _multibytecodecmodule = {
|
|||
PyMODINIT_FUNC
|
||||
PyInit__multibytecodec(void)
|
||||
{
|
||||
int i;
|
||||
PyObject *m;
|
||||
PyTypeObject *typelist[] = {
|
||||
&MultibyteIncrementalEncoder_Type,
|
||||
&MultibyteIncrementalDecoder_Type,
|
||||
&MultibyteStreamReader_Type,
|
||||
&MultibyteStreamWriter_Type,
|
||||
NULL
|
||||
&MultibyteStreamWriter_Type
|
||||
};
|
||||
|
||||
if (PyType_Ready(&MultibyteCodec_Type) < 0)
|
||||
|
@ -2076,12 +2074,10 @@ PyInit__multibytecodec(void)
|
|||
if (m == NULL)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; typelist[i] != NULL; i++) {
|
||||
if (PyType_Ready(typelist[i]) < 0)
|
||||
for (size_t i = 0; i < Py_ARRAY_LENGTH(typelist); i++) {
|
||||
if (PyModule_AddType(m, typelist[i]) < 0) {
|
||||
return NULL;
|
||||
Py_INCREF(typelist[i]);
|
||||
PyModule_AddObject(m, typelist[i]->tp_name,
|
||||
(PyObject *)typelist[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (PyErr_Occurred()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue