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

@ -3844,14 +3844,9 @@ imp_module_exec(PyObject *module)
{
const wchar_t *mode = _Py_GetConfig()->check_hash_pycs_mode;
PyObject *pyc_mode = PyUnicode_FromWideChar(mode, -1);
if (pyc_mode == NULL) {
if (PyModule_Add(module, "check_hash_based_pycs", pyc_mode) < 0) {
return -1;
}
if (PyModule_AddObjectRef(module, "check_hash_based_pycs", pyc_mode) < 0) {
Py_DECREF(pyc_mode);
return -1;
}
Py_DECREF(pyc_mode);
return 0;
}