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

Python/compile.c

Lines changed: 2 additions & 4 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy