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

@ -2189,7 +2189,6 @@ hashlib_init_constructors(PyObject *module)
*/
PyModuleDef *mdef;
PyMethodDef *fdef;
PyObject *proxy;
PyObject *func, *name_obj;
_hashlibstate *state = get_hashlib_state(module);
@ -2224,17 +2223,8 @@ hashlib_init_constructors(PyObject *module)
}
}
proxy = PyDictProxy_New(state->constructs);
if (proxy == NULL) {
return -1;
}
int rc = PyModule_AddObjectRef(module, "_constructors", proxy);
Py_DECREF(proxy);
if (rc < 0) {
return -1;
}
return 0;
return PyModule_Add(module, "_constructors",
PyDictProxy_New(state->constructs));
}
static int