Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
[3.14] gh-145376: Fix various reference leaks (GH-145377)
(cherry picked from commit bd13cc0)

Co-authored-by: Jelle Zijlstra <[email protected]>
  • Loading branch information
JelleZijlstra authored and StanFromIreland committed Mar 9, 2026
commit 9db908037bec79c7d5b3e16e22146d19294d1af0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix reference leaks in various unusual error scenarios.
1 change: 1 addition & 0 deletions Modules/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ pymain_run_interactive_hook(int *exitcode)
}

if (PySys_Audit("cpython.run_interactivehook", "O", hook) < 0) {
Py_DECREF(hook);
goto error;
}

Expand Down
1 change: 1 addition & 0 deletions Python/crossinterp.c
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ check_missing___main___attr(PyObject *exc)
// Get the error message.
PyObject *args = PyException_GetArgs(exc);
if (args == NULL || args == Py_None || PyObject_Size(args) < 1) {
Py_XDECREF(args);
assert(!PyErr_Occurred());
return 0;
}
Expand Down
1 change: 1 addition & 0 deletions Python/pythonrun.c
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,7 @@ _PyErr_Display(PyObject *file, PyObject *unused, PyObject *value, PyObject *tb)
"traceback",
"_print_exception_bltin");
if (print_exception_fn == NULL || !PyCallable_Check(print_exception_fn)) {
Py_XDECREF(print_exception_fn);
goto fallback;
}

Expand Down
2 changes: 1 addition & 1 deletion Python/sysmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1759,7 +1759,7 @@ sys_getwindowsversion_impl(PyObject *module)
PyObject *realVersion = _sys_getwindowsversion_from_kernel32();
if (!realVersion) {
if (!PyErr_ExceptionMatches(PyExc_WindowsError)) {
return NULL;
goto error;
}

PyErr_Clear();
Expand Down
Loading