Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address review comments.
  • Loading branch information
serhiy-storchaka committed Sep 4, 2024
commit 4eaa5fdace45d302e9e8e0cd45f4cf68cc81ebe2
6 changes: 4 additions & 2 deletions Objects/longobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,7 @@ PyLong_AsNativeBytes(PyObject* vv, void* buffer, Py_ssize_t n, int flags)
/* Calculates the number of bits required for the *absolute* value
* of v. This does not take sign into account, only magnitude. */
uint64_t nb = _PyLong_NumBits((PyObject *)v);
/* Normally this would be((nb - 1) / 8) + 1 to avoid rounding up
/* Normally this would be ((nb - 1) / 8) + 1 to avoid rounding up
* multiples of 8 to the next byte, but we add an implied bit for
* the sign and it cancels out. */
res = (Py_ssize_t)(nb / 8) + 1;
Expand Down Expand Up @@ -6175,7 +6175,9 @@ static PyObject *
int_bit_length_impl(PyObject *self)
/*[clinic end generated code: output=fc1977c9353d6a59 input=e4eb7a587e849a32]*/
{
return PyLong_FromUInt64(_PyLong_NumBits(self));
uint64_t nbits =_PyLong_NumBits(self);
Comment thread
serhiy-storchaka marked this conversation as resolved.
Outdated
assert(!PyErr_Occurred());
return PyLong_FromUInt64(nbits);
}

static int
Expand Down