Skip to content

Commit e6354c3

Browse files
committed
Enter the recursion guard once per Tcl list, not per element
1 parent 2861120 commit e6354c3

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

‎Modules/_tkinter.c‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,24 +1403,25 @@ FromObj(TkappObject *tkapp, Tcl_Obj *value)
14031403
result = PyTuple_New(size);
14041404
if (!result)
14051405
return NULL;
1406+
if (Py_EnterRecursiveCall(" while converting a Tcl list")) {
1407+
Py_DECREF(result);
1408+
return NULL;
1409+
}
14061410
for (i = 0; i < size; i++) {
14071411
status = Tcl_ListObjIndex(interp, value, i, &tcl_elem);
14081412
if (status == TCL_ERROR) {
1409-
Py_DECREF(result);
1410-
return Tkinter_Error(tkapp);
1411-
}
1412-
if (Py_EnterRecursiveCall(" while converting a Tcl list")) {
1413-
Py_DECREF(result);
1414-
return NULL;
1413+
Tkinter_Error(tkapp);
1414+
Py_CLEAR(result);
1415+
break;
14151416
}
14161417
elem = FromObj(tkapp, tcl_elem);
1417-
Py_LeaveRecursiveCall();
14181418
if (!elem) {
1419-
Py_DECREF(result);
1420-
return NULL;
1419+
Py_CLEAR(result);
1420+
break;
14211421
}
14221422
PyTuple_SET_ITEM(result, i, elem);
14231423
}
1424+
Py_LeaveRecursiveCall();
14241425
return result;
14251426
}
14261427

0 commit comments

Comments
 (0)