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().
diff --git a/Modules/_bz2module.c b/Modules/_bz2module.c
index fe58809..008aef0 100644
--- a/Modules/_bz2module.c
+++ b/Modules/_bz2module.c
@@ -731,24 +731,11 @@
static int
_bz2_exec(PyObject *module)
{
- if (PyType_Ready(&BZ2Compressor_Type) < 0) {
- return -1;
- }
- if (PyType_Ready(&BZ2Decompressor_Type) < 0) {
+ if (PyModule_AddType(module, &BZ2Compressor_Type) < 0) {
return -1;
}
- Py_INCREF(&BZ2Compressor_Type);
- if (PyModule_AddObject(module, "BZ2Compressor",
- (PyObject *)&BZ2Compressor_Type) < 0) {
- Py_DECREF(&BZ2Compressor_Type);
- return -1;
- }
-
- Py_INCREF(&BZ2Decompressor_Type);
- if (PyModule_AddObject(module, "BZ2Decompressor",
- (PyObject *)&BZ2Decompressor_Type) < 0) {
- Py_INCREF(&BZ2Decompressor_Type);
+ if (PyModule_AddType(module, &BZ2Decompressor_Type) < 0) {
return -1;
}