summaryrefslogtreecommitdiffstats
path: root/Modules/socketmodule.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2023-07-18 20:59:53 (GMT)
committerGitHub <noreply@github.com>2023-07-18 20:59:53 (GMT)
commita293fa5915c21b21f5cb8ed9649fbdb37b4c1421 (patch)
tree4d7ca05e79dad8e2e21024896fb7e5c17624e70b /Modules/socketmodule.c
parent40f3f11a773b854c6d94746aa3b1881c8ac71b0f (diff)
downloadcpython-a293fa5915c21b21f5cb8ed9649fbdb37b4c1421.zip
cpython-a293fa5915c21b21f5cb8ed9649fbdb37b4c1421.tar.gz
cpython-a293fa5915c21b21f5cb8ed9649fbdb37b4c1421.tar.bz2
gh-86493: Use PyModule_Add() instead of PyModule_AddObjectRef() (GH-106860)
Diffstat (limited to 'Modules/socketmodule.c')
-rw-r--r--Modules/socketmodule.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 1d3f34b..39bbc91 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -7425,9 +7425,7 @@ socket_exec(PyObject *m)
sock_free_api(capi);
goto error;
}
- int rc = PyModule_AddObjectRef(m, PySocket_CAPI_NAME, capsule);
- Py_DECREF(capsule);
- if (rc < 0) {
+ if (PyModule_Add(m, PySocket_CAPI_NAME, capsule) < 0) {
goto error;
}
@@ -8818,13 +8816,7 @@ socket_exec(PyObject *m)
};
int i;
for (i = 0; i < Py_ARRAY_LENGTH(codes); ++i) {
- PyObject *tmp = PyLong_FromUnsignedLong(codes[i]);
- if (tmp == NULL) {
- goto error;
- }
- int rc = PyModule_AddObjectRef(m, names[i], tmp);
- Py_DECREF(tmp);
- if (rc < 0) {
+ if (PyModule_Add(m, names[i], PyLong_FromUnsignedLong(codes[i])) < 0) {
goto error;
}
}