summaryrefslogtreecommitdiffstats
path: root/Modules/cjkcodecs
diff options
context:
space:
mode:
authorDong-hee Na <donghee.na92@gmail.com>2020-03-24 22:08:51 (GMT)
committerGitHub <noreply@github.com>2020-03-24 22:08:51 (GMT)
commit37fcbb65d4589fbb5a72153e9338cf8e6495f64f (patch)
treee0c1e2f0b9d5673779ec74b71fef3fc158158ae1 /Modules/cjkcodecs
parent15e5024d04fc89d948ae761d88048bc58a56b650 (diff)
downloadcpython-37fcbb65d4589fbb5a72153e9338cf8e6495f64f.zip
cpython-37fcbb65d4589fbb5a72153e9338cf8e6495f64f.tar.gz
cpython-37fcbb65d4589fbb5a72153e9338cf8e6495f64f.tar.bz2
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().
Diffstat (limited to 'Modules/cjkcodecs')
-rw-r--r--Modules/cjkcodecs/multibytecodec.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c
index 3bc07b2..a09c75d 100644
--- a/Modules/cjkcodecs/multibytecodec.c
+++ b/Modules/cjkcodecs/multibytecodec.c
@@ -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()) {