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 1f2d47c commit 649c311Copy full SHA for 649c311
Objects/longobject.c
@@ -273,8 +273,9 @@ PyLong_FromLong(long ival)
273
if (!(abs_ival >> PyLong_SHIFT)) {
274
return _PyLong_FromMedium((sdigit)ival);
275
}
276
- /* Must be at least two digits */
277
- unsigned long t = abs_ival >> (PyLong_SHIFT *2);
+ /* Must be at least two digits.
+ * Do shift in two steps to avoid undefined behavior. */
278
+ unsigned long t = (abs_ival >> PyLong_SHIFT) >> PyLong_SHIFT;
279
Py_ssize_t ndigits = 2;
280
while (t) {
281
++ndigits;
0 commit comments