diff options
| author | Serhiy Storchaka <storchaka@gmail.com> | 2024-07-17 08:04:45 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-17 08:04:45 (GMT) |
| commit | 09ff4ec14f4285aca1ddf907274e2bb3a1fbb6a1 (patch) | |
| tree | 9778290fb77610cdd63f0026c6037991e7e24ec0 /Python | |
| parent | d358f74a695b41b2b494b82df7ce3fd719dfac9c (diff) | |
| download | cpython-09ff4ec14f4285aca1ddf907274e2bb3a1fbb6a1.zip cpython-09ff4ec14f4285aca1ddf907274e2bb3a1fbb6a1.tar.gz cpython-09ff4ec14f4285aca1ddf907274e2bb3a1fbb6a1.tar.bz2 | |
[3.13] gh-121153: Fix some errors with use of _PyLong_CompactValue() (GH-121154) (GH-121900)
* The result has type Py_ssize_t, not intptr_t.
* Type cast between unsigned and signed integer types should be explicit.
* Downcasting should be explicit.
* Fix integer overflow check in sum().
(cherry picked from commit 1801545)
Diffstat (limited to 'Python')
| -rw-r--r-- | Python/bltinmodule.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 8f36857..5afa94c 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -2601,8 +2601,8 @@ builtin_sum_impl(PyObject *module, PyObject *iterable, PyObject *start) b = PyLong_AsLongAndOverflow(item, &overflow); } if (overflow == 0 && - (i_result >= 0 ? (b <= LONG_MAX - i_result) - : (b >= LONG_MIN - i_result))) + (i_result >= 0 ? (b <= PY_SSIZE_T_MAX - i_result) + : (b >= PY_SSIZE_T_MIN - i_result))) { i_result += b; Py_DECREF(item); |
