diff options
author | Victor Stinner <vstinner@python.org> | 2020-09-23 12:06:55 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-23 12:06:55 (GMT) |
commit | 71f2ff4ccf4ff8bdb56cc30d115ca2ddc602b12f (patch) | |
tree | 0c7f83c058836bd2533992142c2b4692f6c70ce6 | |
parent | 7f413a5d95e6d7ddddd6e2c9844c33594d6288f4 (diff) | |
download | cpython-71f2ff4ccf4ff8bdb56cc30d115ca2ddc602b12f.zip cpython-71f2ff4ccf4ff8bdb56cc30d115ca2ddc602b12f.tar.gz cpython-71f2ff4ccf4ff8bdb56cc30d115ca2ddc602b12f.tar.bz2 |
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.
-rw-r--r-- | Python/compile.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/Python/compile.c b/Python/compile.c index 3ebf221..0f9e5c2 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -6100,13 +6100,11 @@ fold_tuple_on_constants(struct instr *inst, PyTuple_SET_ITEM(newconst, i, constant); } Py_ssize_t index = PyList_GET_SIZE(consts); -#if SIZEOF_SIZE_T > SIZEOF_INT - if ((size_t)index >= UINT_MAX - 1) { + if ((size_t)index >= (size_t)INT_MAX - 1) { Py_DECREF(newconst); PyErr_SetString(PyExc_OverflowError, "too many constants"); return -1; } -#endif if (PyList_Append(consts, newconst)) { Py_DECREF(newconst); return -1; @@ -6116,7 +6114,7 @@ fold_tuple_on_constants(struct instr *inst, inst[i].i_opcode = NOP; } inst[n].i_opcode = LOAD_CONST; - inst[n].i_oparg = index; + inst[n].i_oparg = (int)index; return 0; } |