summaryrefslogtreecommitdiffstats
path: root/Modules/_testmultiphase.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2023-07-25 11:34:49 (GMT)
committerGitHub <noreply@github.com>2023-07-25 11:34:49 (GMT)
commit329e4a1a3f8c53d9d120d2eed93b95a04b826f2f (patch)
tree8bbe3eb47cf37493fcd3289d98643605e0217c78 /Modules/_testmultiphase.c
parentf443b54a2f14e386a91fe4b09f41a265445008b8 (diff)
downloadcpython-329e4a1a3f8c53d9d120d2eed93b95a04b826f2f.zip
cpython-329e4a1a3f8c53d9d120d2eed93b95a04b826f2f.tar.gz
cpython-329e4a1a3f8c53d9d120d2eed93b95a04b826f2f.tar.bz2
gh-86493: Modernize modules initialization code (GH-106858)
Use PyModule_Add() or PyModule_AddObjectRef() instead of soft deprecated PyModule_AddObject().
Diffstat (limited to 'Modules/_testmultiphase.c')
-rw-r--r--Modules/_testmultiphase.c24
1 files changed, 4 insertions, 20 deletions
diff --git a/Modules/_testmultiphase.c b/Modules/_testmultiphase.c
index ca71b61..fdef061 100644
--- a/Modules/_testmultiphase.c
+++ b/Modules/_testmultiphase.c
@@ -383,32 +383,20 @@ static int execfunc(PyObject *m)
/* Add a custom type */
temp = PyType_FromSpec(&Example_Type_spec);
- if (temp == NULL) {
- goto fail;
- }
- if (PyModule_AddObject(m, "Example", temp) != 0) {
- Py_DECREF(temp);
+ if (PyModule_Add(m, "Example", temp) != 0) {
goto fail;
}
/* Add an exception type */
temp = PyErr_NewException("_testimportexec.error", NULL, NULL);
- if (temp == NULL) {
- goto fail;
- }
- if (PyModule_AddObject(m, "error", temp) != 0) {
- Py_DECREF(temp);
+ if (PyModule_Add(m, "error", temp) != 0) {
goto fail;
}
/* Add Str */
temp = PyType_FromSpec(&Str_Type_spec);
- if (temp == NULL) {
- goto fail;
- }
- if (PyModule_AddObject(m, "Str", temp) != 0) {
- Py_DECREF(temp);
+ if (PyModule_Add(m, "Str", temp) != 0) {
goto fail;
}
@@ -857,11 +845,7 @@ meth_state_access_exec(PyObject *m)
}
temp = PyType_FromModuleAndSpec(m, &StateAccessType_spec, NULL);
- if (temp == NULL) {
- return -1;
- }
- if (PyModule_AddObject(m, "StateAccessType", temp) != 0) {
- Py_DECREF(temp);
+ if (PyModule_Add(m, "StateAccessType", temp) != 0) {
return -1;
}