Skip to content

Commit ef9277a

Browse files
Fix MAX_LONG_DIGITS on 32-bit platforms.
1 parent ee87e7f commit ef9277a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Objects/floatobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,14 +412,14 @@ float_richcompare(PyObject *v, PyObject *w, int op)
412412
/* The signs are the same. */
413413
/* Convert w to a double if it fits. In particular, 0 fits. */
414414
uint64_t nbits64 = _PyLong_NumBits(w);
415+
assert(!PyErr_Occurred());
415416
if (nbits64 > (unsigned int)DBL_MAX_EXP) {
416417
/* This Python integer is larger than any finite C double.
417418
* Replace with little doubles
418419
* that give the same outcome -- w is so large that
419420
* its magnitude must exceed the magnitude of any
420421
* finite float.
421422
*/
422-
assert(!PyErr_Occurred());
423423
i = (double)vsign;
424424
assert(wsign != 0);
425425
j = wsign * 2.0;

Objects/longobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,15 @@ long_normalize(PyLongObject *v)
133133
/* Allocate a new int object with size digits.
134134
Return NULL and set exception if we run out of memory. */
135135

136-
#if SIZEOF_SIZE_T < 4
136+
#if SIZEOF_SIZE_T < 8
137137
# define MAX_LONG_DIGITS \
138138
((PY_SSIZE_T_MAX - offsetof(PyLongObject, long_value.ob_digit))/sizeof(digit))
139139
#else
140140
/* Guarantee that the number of bits fits in uint64_t.
141141
This is more than 2 exbibytes, that is more than many of modern
142142
architectures support in principle.
143143
-1 is added to avoid overflow in _PyLong_Frexp(). */
144-
# define MAX_LONG_DIGITS ((UINT64_MAX-1) / (uint64_t)PyLong_SHIFT)
144+
# define MAX_LONG_DIGITS ((UINT64_MAX-1U) / (uint64_t)PyLong_SHIFT)
145145
#endif
146146

147147
PyLongObject *

0 commit comments

Comments
 (0)