Skip to content
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
fix refleak
  • Loading branch information
iritkatriel committed Mar 18, 2023
commit 103dc3c4f6ac0b204a17565dcf6644f660e24365
4 changes: 3 additions & 1 deletion Python/import.c
Original file line number Diff line number Diff line change
Expand Up @@ -2324,6 +2324,7 @@ remove_importlib_frames(PyThreadState *tstate)
int always_trim = 0;
int in_importlib = 0;
PyObject **prev_link, **outer_link = NULL;
PyObject *base_tb = NULL;

/* Synopsis: if it's an ImportError, we trim all importlib chunks
from the traceback. We always trim chunks
Expand All @@ -2339,7 +2340,7 @@ remove_importlib_frames(PyThreadState *tstate)
}

assert(PyExceptionInstance_Check(exc));
PyObject *base_tb = PyException_GetTraceback(exc);
base_tb = PyException_GetTraceback(exc);
prev_link = &base_tb;
PyObject *tb = base_tb;
while (tb != NULL) {
Expand Down Expand Up @@ -2376,6 +2377,7 @@ remove_importlib_frames(PyThreadState *tstate)
}
PyException_SetTraceback(exc, base_tb);
done:
Py_XDECREF(base_tb);
_PyErr_SetRaisedException(tstate, exc);
}

Expand Down