summaryrefslogtreecommitdiffstats
path: root/Modules/_io
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/_io
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/_io')
-rw-r--r--Modules/_io/_iomodule.c36
1 files changed, 16 insertions, 20 deletions
diff --git a/Modules/_io/_iomodule.c b/Modules/_io/_iomodule.c
index 5ceae62..e880992 100644
--- a/Modules/_io/_iomodule.c
+++ b/Modules/_io/_iomodule.c
@@ -684,12 +684,8 @@ PyInit__io(void)
state = get_io_state(m);
state->initialized = 0;
-#define ADD_TYPE(type, name) \
- if (PyType_Ready(type) < 0) \
- goto fail; \
- Py_INCREF(type); \
- if (PyModule_AddObject(m, name, (PyObject *)type) < 0) { \
- Py_DECREF(type); \
+#define ADD_TYPE(type) \
+ if (PyModule_AddType(m, type) < 0) { \
goto fail; \
}
@@ -717,54 +713,54 @@ PyInit__io(void)
/* Concrete base types of the IO ABCs.
(the ABCs themselves are declared through inheritance in io.py)
*/
- ADD_TYPE(&PyIOBase_Type, "_IOBase");
- ADD_TYPE(&PyRawIOBase_Type, "_RawIOBase");
- ADD_TYPE(&PyBufferedIOBase_Type, "_BufferedIOBase");
- ADD_TYPE(&PyTextIOBase_Type, "_TextIOBase");
+ ADD_TYPE(&PyIOBase_Type);
+ ADD_TYPE(&PyRawIOBase_Type);
+ ADD_TYPE(&PyBufferedIOBase_Type);
+ ADD_TYPE(&PyTextIOBase_Type);
/* Implementation of concrete IO objects. */
/* FileIO */
PyFileIO_Type.tp_base = &PyRawIOBase_Type;
- ADD_TYPE(&PyFileIO_Type, "FileIO");
+ ADD_TYPE(&PyFileIO_Type);
/* BytesIO */
PyBytesIO_Type.tp_base = &PyBufferedIOBase_Type;
- ADD_TYPE(&PyBytesIO_Type, "BytesIO");
+ ADD_TYPE(&PyBytesIO_Type);
if (PyType_Ready(&_PyBytesIOBuffer_Type) < 0)
goto fail;
/* StringIO */
PyStringIO_Type.tp_base = &PyTextIOBase_Type;
- ADD_TYPE(&PyStringIO_Type, "StringIO");
+ ADD_TYPE(&PyStringIO_Type);
#ifdef MS_WINDOWS
/* WindowsConsoleIO */
PyWindowsConsoleIO_Type.tp_base = &PyRawIOBase_Type;
- ADD_TYPE(&PyWindowsConsoleIO_Type, "_WindowsConsoleIO");
+ ADD_TYPE(&PyWindowsConsoleIO_Type);
#endif
/* BufferedReader */
PyBufferedReader_Type.tp_base = &PyBufferedIOBase_Type;
- ADD_TYPE(&PyBufferedReader_Type, "BufferedReader");
+ ADD_TYPE(&PyBufferedReader_Type);
/* BufferedWriter */
PyBufferedWriter_Type.tp_base = &PyBufferedIOBase_Type;
- ADD_TYPE(&PyBufferedWriter_Type, "BufferedWriter");
+ ADD_TYPE(&PyBufferedWriter_Type);
/* BufferedRWPair */
PyBufferedRWPair_Type.tp_base = &PyBufferedIOBase_Type;
- ADD_TYPE(&PyBufferedRWPair_Type, "BufferedRWPair");
+ ADD_TYPE(&PyBufferedRWPair_Type);
/* BufferedRandom */
PyBufferedRandom_Type.tp_base = &PyBufferedIOBase_Type;
- ADD_TYPE(&PyBufferedRandom_Type, "BufferedRandom");
+ ADD_TYPE(&PyBufferedRandom_Type);
/* TextIOWrapper */
PyTextIOWrapper_Type.tp_base = &PyTextIOBase_Type;
- ADD_TYPE(&PyTextIOWrapper_Type, "TextIOWrapper");
+ ADD_TYPE(&PyTextIOWrapper_Type);
/* IncrementalNewlineDecoder */
- ADD_TYPE(&PyIncrementalNewlineDecoder_Type, "IncrementalNewlineDecoder");
+ ADD_TYPE(&PyIncrementalNewlineDecoder_Type);
/* Interned strings */
#define ADD_INTERNED(name) \