diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2024-08-30 05:13:24 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-30 05:13:24 (GMT) |
commit | 32c7dbb2bc58bee953622fc5ac24aad123f0d8f2 (patch) | |
tree | c77954d29b817d4a49ec547fd0d5117461b58cdf /Python/ast_opt.c | |
parent | 58ce131037ecb34d506a613f21993cde2056f628 (diff) | |
download | cpython-32c7dbb2bc58bee953622fc5ac24aad123f0d8f2.zip cpython-32c7dbb2bc58bee953622fc5ac24aad123f0d8f2.tar.gz cpython-32c7dbb2bc58bee953622fc5ac24aad123f0d8f2.tar.bz2 |
gh-121485: Always use 64-bit integers for integers bits count (GH-121486)
Use 64-bit integers instead of platform specific size_t or Py_ssize_t
to represent the number of bits in Python integer.
Diffstat (limited to 'Python/ast_opt.c')
-rw-r--r-- | Python/ast_opt.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Python/ast_opt.c b/Python/ast_opt.c index 503715e..5a51305 100644 --- a/Python/ast_opt.c +++ b/Python/ast_opt.c @@ -169,9 +169,9 @@ safe_multiply(PyObject *v, PyObject *w) if (PyLong_Check(v) && PyLong_Check(w) && !_PyLong_IsZero((PyLongObject *)v) && !_PyLong_IsZero((PyLongObject *)w) ) { - size_t vbits = _PyLong_NumBits(v); - size_t wbits = _PyLong_NumBits(w); - if (vbits == (size_t)-1 || wbits == (size_t)-1) { + uint64_t vbits = _PyLong_NumBits(v); + uint64_t wbits = _PyLong_NumBits(w); + if (vbits == (uint64_t)-1 || wbits == (uint64_t)-1) { return NULL; } if (vbits + wbits > MAX_INT_SIZE) { @@ -215,9 +215,9 @@ safe_power(PyObject *v, PyObject *w) if (PyLong_Check(v) && PyLong_Check(w) && !_PyLong_IsZero((PyLongObject *)v) && _PyLong_IsPositive((PyLongObject *)w) ) { - size_t vbits = _PyLong_NumBits(v); + uint64_t vbits = _PyLong_NumBits(v); size_t wbits = PyLong_AsSize_t(w); - if (vbits == (size_t)-1 || wbits == (size_t)-1) { + if (vbits == (uint64_t)-1 || wbits == (size_t)-1) { return NULL; } if (vbits > MAX_INT_SIZE / wbits) { @@ -234,9 +234,9 @@ safe_lshift(PyObject *v, PyObject *w) if (PyLong_Check(v) && PyLong_Check(w) && !_PyLong_IsZero((PyLongObject *)v) && !_PyLong_IsZero((PyLongObject *)w) ) { - size_t vbits = _PyLong_NumBits(v); + uint64_t vbits = _PyLong_NumBits(v); size_t wbits = PyLong_AsSize_t(w); - if (vbits == (size_t)-1 || wbits == (size_t)-1) { + if (vbits == (uint64_t)-1 || wbits == (size_t)-1) { return NULL; } if (wbits > MAX_INT_SIZE || vbits > MAX_INT_SIZE - wbits) { |