summaryrefslogtreecommitdiffstats
path: root/Modules/_weakref.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/_weakref.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/_weakref.c')
-rw-r--r--Modules/_weakref.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/Modules/_weakref.c b/Modules/_weakref.c
index dcb2984..4e2862e 100644
--- a/Modules/_weakref.c
+++ b/Modules/_weakref.c
@@ -144,27 +144,19 @@ weakref_functions[] = {
static int
weakref_exec(PyObject *module)
{
- Py_INCREF(&_PyWeakref_RefType);
- if (PyModule_AddObject(module, "ref", (PyObject *) &_PyWeakref_RefType) < 0) {
- Py_DECREF(&_PyWeakref_RefType);
+ if (PyModule_AddObjectRef(module, "ref", (PyObject *) &_PyWeakref_RefType) < 0) {
return -1;
}
- Py_INCREF(&_PyWeakref_RefType);
- if (PyModule_AddObject(module, "ReferenceType",
+ if (PyModule_AddObjectRef(module, "ReferenceType",
(PyObject *) &_PyWeakref_RefType) < 0) {
- Py_DECREF(&_PyWeakref_RefType);
return -1;
}
- Py_INCREF(&_PyWeakref_ProxyType);
- if (PyModule_AddObject(module, "ProxyType",
+ if (PyModule_AddObjectRef(module, "ProxyType",
(PyObject *) &_PyWeakref_ProxyType) < 0) {
- Py_DECREF(&_PyWeakref_ProxyType);
return -1;
}
- Py_INCREF(&_PyWeakref_CallableProxyType);
- if (PyModule_AddObject(module, "CallableProxyType",
+ if (PyModule_AddObjectRef(module, "CallableProxyType",
(PyObject *) &_PyWeakref_CallableProxyType) < 0) {
- Py_DECREF(&_PyWeakref_CallableProxyType);
return -1;
}