gh-83004: Clean up refleak in _pickle initialisation (#98841)

This commit is contained in:
Shantanu 2022-11-06 06:05:13 -08:00 committed by GitHub
parent 31f2f6568d
commit d3b82b4463
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -0,0 +1 @@
Clean up refleaks on failed module initialisation in in :mod:`_pickle`

View File

@ -7986,16 +7986,15 @@ PyInit__pickle(void)
if (st->UnpicklingError == NULL)
return NULL;
Py_INCREF(st->PickleError);
if (PyModule_AddObject(m, "PickleError", st->PickleError) < 0)
if (PyModule_AddObjectRef(m, "PickleError", st->PickleError) < 0) {
return NULL;
Py_INCREF(st->PicklingError);
if (PyModule_AddObject(m, "PicklingError", st->PicklingError) < 0)
}
if (PyModule_AddObjectRef(m, "PicklingError", st->PicklingError) < 0) {
return NULL;
Py_INCREF(st->UnpicklingError);
if (PyModule_AddObject(m, "UnpicklingError", st->UnpicklingError) < 0)
}
if (PyModule_AddObjectRef(m, "UnpicklingError", st->UnpicklingError) < 0) {
return NULL;
}
if (_Pickle_InitState(st) < 0)
return NULL;