Skip to content

Commit 932c15e

Browse files
committed
fix: should set the error when no memory
Signed-off-by: yihong0618 <[email protected]>
1 parent 095f865 commit 932c15e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Python/ceval.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,11 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
914914
if (lasti == NULL) {
915915
// gh-134163: If we can't allocate memory for lasti during exception handling,
916916
// this likely means we're in a severe memory shortage situation.
917+
if (!_PyErr_Occurred(tstate)) {
918+
// PyLong_FromLong should have set an exception
919+
// like _testcapi.set_nomemory(0), it might not. Ensure one is set.
920+
PyErr_NoMemory();
921+
}
917922
// Instead of going back to exception_unwind (which would cause
918923
// infinite recursion), directly exit to let the original exception
919924
// propagate up and hopefully be handled at a higher level.

0 commit comments

Comments
 (0)