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

@ -1756,22 +1756,12 @@ static int
_json_exec(PyObject *module)
{
PyObject *PyScannerType = PyType_FromSpec(&PyScannerType_spec);
if (PyScannerType == NULL) {
return -1;
}
int rc = PyModule_AddObjectRef(module, "make_scanner", PyScannerType);
Py_DECREF(PyScannerType);
if (rc < 0) {
if (PyModule_Add(module, "make_scanner", PyScannerType) < 0) {
return -1;
}
PyObject *PyEncoderType = PyType_FromSpec(&PyEncoderType_spec);
if (PyEncoderType == NULL) {
return -1;
}
rc = PyModule_AddObjectRef(module, "make_encoder", PyEncoderType);
Py_DECREF(PyEncoderType);
if (rc < 0) {
if (PyModule_Add(module, "make_encoder", PyEncoderType) < 0) {
return -1;
}