We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2cb1aec commit 99c5420Copy full SHA for 99c5420
Objects/longobject.c
@@ -361,9 +361,10 @@ PyLong_FromLong(long ival)
361
if ((ival) <= PyLong_MASK) { \
362
return _PyLong_FromMedium((sdigit)(ival)); \
363
} \
364
+ /* Do shift in two steps to avoid possible undefined behavior. */ \
365
+ INT_TYPE t = (ival) >> PyLong_SHIFT >> PyLong_SHIFT; \
366
/* Count the number of Python digits. */ \
- Py_ssize_t ndigits = 0; \
- INT_TYPE t = (ival); \
367
+ Py_ssize_t ndigits = 2; \
368
while (t) { \
369
++ndigits; \
370
t >>= PyLong_SHIFT; \
0 commit comments