8000 gh-83004: Clean up refleak in _pickle initialisation by hauntsaninja · Pull Request #98841 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 6, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
actually use PyModule_AddObjectRef
  • Loading branch information
hauntsaninja committed Oct 29, 2022
commit 9ae0e272b5032eb3605d7064b5e1c7343d594705
12 changes: 3 additions & 9 deletions Modules/_pickle.c
Original file line number Diff line number Diff line change
Expand Up @@ -7986,19 +7986,13 @@ PyInit__pickle(void)
if (st->UnpicklingError == NULL)
return NULL;

Py_INCREF(st->PickleError);
if (PyModule_AddObject(m, "PickleError", st->PickleError) < 0) {
Py_DECREF(st->PickleError);
if (PyModule_AddObjectRef(m, "PickleError", st->PickleError) < 0) {
return NULL;
}
Py_INCREF(st->PicklingError);
if (PyModule_AddObject(m, "PicklingError", st->PicklingError) < 0) {
Py_DECREF(st->PicklingError);
if (PyModule_AddObjectRef(m, "PicklingError", st->PicklingError) < 0) {
return NULL;
}
Py_INCREF(st->UnpicklingError);
if (PyModule_AddObject(m, "UnpicklingError", st->UnpicklingError) < 0) {
Py_DECREF(st->UnpicklingError);
if (PyModule_AddObjectRef(m, "UnpicklingError", st->UnpicklingError) < 0) {
return NULL;
}
if (_Pickle_InitState(st) < 0)
Expand Down
0