gh-86493: Use PyModule_Add() instead of PyModule_AddObjectRef() (GH-106860)

This commit is contained in:
Serhiy Storchaka 2023-07-18 23:59:53 +03:00 committed by GitHub
parent 40f3f11a77
commit a293fa5915
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 26 additions and 116 deletions

View file

@ -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;
}
}