Skip to content

Commit 99c5420

Browse files
committed
Address review comments
1 parent 2cb1aec commit 99c5420

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Objects/longobject.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,10 @@ PyLong_FromLong(long ival)
361361
if ((ival) <= PyLong_MASK) { \
362362
return _PyLong_FromMedium((sdigit)(ival)); \
363363
} \
364+
/* Do shift in two steps to avoid possible undefined behavior. */ \
365+
INT_TYPE t = (ival) >> PyLong_SHIFT >> PyLong_SHIFT; \
364366
/* Count the number of Python digits. */ \
365-
Py_ssize_t ndigits = 0; \
366-
INT_TYPE t = (ival); \
367+
Py_ssize_t ndigits = 2; \
367368
while (t) { \
368369
++ndigits; \
369370
t >>= PyLong_SHIFT; \

0 commit comments

Comments
 (0)