Skip to content

Commit 1b79da4

Browse files
committed
Fix a compiler warning in _randommodule.c
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
1 parent 579b2f8 commit 1b79da4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Modules/_randommodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ _random_Random_getrandbits_impl(RandomObject *self, uint64_t k)
522522
PyErr_NoMemory();
523523
return NULL;
524524
}
525-
words = (k - 1u) / 32u + 1u;
525+
words = (Py_ssize_t)((k - 1u) / 32u + 1u);
526526
wordarray = (uint32_t *)PyMem_Malloc(words * 4);
527527
if (wordarray == NULL) {
528528
PyErr_NoMemory();

0 commit comments

Comments
 (0)