Skip to content

Commit 71f2ff4

Browse files
authored
bpo-40941: Fix fold_tuple_on_constants() compiler warnings (GH-22378)
Add explicit casts to fix compiler warnings in fold_tuple_on_constants(). The limit of constants per code is now INT_MAX, rather than UINT_MAX.
1 parent 7f413a5 commit 71f2ff4

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

Diff for: Python/compile.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -6100,13 +6100,11 @@ fold_tuple_on_constants(struct instr *inst,
61006100
PyTuple_SET_ITEM(newconst, i, constant);
61016101
}
61026102
Py_ssize_t index = PyList_GET_SIZE(consts);
6103-
#if SIZEOF_SIZE_T > SIZEOF_INT
6104-
if ((size_t)index >= UINT_MAX - 1) {
6103+
if ((size_t)index >= (size_t)INT_MAX - 1) {
61056104
Py_DECREF(newconst);
61066105
PyErr_SetString(PyExc_OverflowError, "too many constants");
61076106
return -1;
61086107
}
6109-
#endif
61106108
if (PyList_Append(consts, newconst)) {
61116109
Py_DECREF(newconst);
61126110
return -1;
@@ -6116,7 +6114,7 @@ fold_tuple_on_constants(struct instr *inst,
61166114
inst[i].i_opcode = NOP;
61176115
}
61186116
inst[n].i_opcode = LOAD_CONST;
6119-
inst[n].i_oparg = index;
6117+
inst[n].i_oparg = (int)index;
61206118
return 0;
61216119
}
61226120

0 commit comments

Comments
 (0)