From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Wed, 5 Nov 2025 19:08:41 +0000 (+0100) Subject: [3.13] Fix a compiler warning in _randommodule.c (GH-141058) (#141064) X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3ecf63754ea2ea4114c9ec51d0b95ca218762706;p=thirdparty%2FPython%2Fcpython.git [3.13] Fix a compiler warning in _randommodule.c (GH-141058) (#141064) Fix a compiler warning in _randommodule.c (GH-141058) The test just before the cast ensures that the cast cannot overflow. Fix the warning on 32-bit Windows: Modules\_randommodule.c(525,28): warning C4244: '=': conversion from 'uint64_t' to 'Py_ssize_t', possible loss of data (cherry picked from commit 4ac16dd10950fad2d3e58e8b0ba5f2e621af3cc1) Co-authored-by: Victor Stinner --- diff --git a/Modules/_randommodule.c b/Modules/_randommodule.c index 6a311bb0d71f..2d3909f7f30e 100644 --- a/Modules/_randommodule.c +++ b/Modules/_randommodule.c @@ -526,7 +526,7 @@ _random_Random_getrandbits_impl(RandomObject *self, long long k) PyErr_NoMemory(); return NULL; } - words = (k - 1u) / 32u + 1u; + words = (Py_ssize_t)((k - 1u) / 32u + 1u); wordarray = (uint32_t *)PyMem_Malloc(words * 4); if (wordarray == NULL) { PyErr_NoMemory();