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

(cherry picked from commit d3b82b4463)

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2022-11-06 06:41:24 -08:00 committed by GitHub
parent 4b1e45e78b
commit 57077928ec
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

@ -7998,16 +7998,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;