Skip to content

Commit 661d057

Browse files
committed
added guard to ensure the new logics can only be triggered through eval/exec
1 parent 087a135 commit 661d057

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Python/ceval.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2476,7 +2476,8 @@ _PyEvalFramePushAndInit(PyThreadState *tstate, _PyStackRef func,
24762476
goto fail;
24772477
}
24782478
_PyFrame_Initialize(tstate, frame, func, locals, code, 0, previous);
2479-
if (code->co_flags & CO_OPTIMIZED && locals != NULL && locals != func_obj->func_globals) {
2479+
if (code->co_flags & CO_OPTIMIZED && locals != NULL && locals != func_obj->func_globals &&
2480+
kwnames == NULL) { /* kwnames can be NULL only when invoked through PyEval_EvalCode */
24802481
for (size_t i = 0; i < argcount; i++) {
24812482
PyStackRef_CLOSE(args[i]);
24822483
}

0 commit comments

Comments
 (0)