Skip to content

Commit 4eaa5fd

Browse files
Address review comments.
1 parent 7c3d3fc commit 4eaa5fd

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Objects/longobject.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,7 @@ PyLong_AsNativeBytes(PyObject* vv, void* buffer, Py_ssize_t n, int flags)
12471247
/* Calculates the number of bits required for the *absolute* value
12481248
* of v. This does not take sign into account, only magnitude. */
12491249
uint64_t nb = _PyLong_NumBits((PyObject *)v);
1250-
/* Normally this would be((nb - 1) / 8) + 1 to avoid rounding up
1250+
/* Normally this would be ((nb - 1) / 8) + 1 to avoid rounding up
12511251
* multiples of 8 to the next byte, but we add an implied bit for
12521252
* the sign and it cancels out. */
12531253
res = (Py_ssize_t)(nb / 8) + 1;
@@ -6175,7 +6175,9 @@ static PyObject *
61756175
int_bit_length_impl(PyObject *self)
61766176
/*[clinic end generated code: output=fc1977c9353d6a59 input=e4eb7a587e849a32]*/
61776177
{
6178-
return PyLong_FromUInt64(_PyLong_NumBits(self));
6178+
uint64_t nbits =_PyLong_NumBits(self);
6179+
assert(!PyErr_Occurred());
6180+
return PyLong_FromUInt64(nbits);
61796181
}
61806182

61816183
static int

0 commit comments

Comments
 (0)