8000 _PyLong_NumBits returns int64_t now. · python/cpython@71d7f4f · GitHub
[go: up one dir, main page]

Skip to content

Commit 71d7f4f

Browse files
_PyLong_NumBits returns int64_t now.
1 parent 091dab6 commit 71d7f4f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Modules/imathmodule.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ static PyObject *
164164
imath_ilog2(PyObject *module, PyObject *n)
165165
/*[clinic end generated code: output=6ab48d1a7f5160c2 input=e2d8e8631ec5c29b]*/
166166
{
167-
size_t bits;
167+
int64_t bits;
168168

169169
n = PyNumber_Index(n);
170170
if (n == NULL) {
@@ -174,17 +174,17 @@ imath_ilog2(PyObject *module, PyObject *n)
174174
if (!_PyLong_IsPositive((PyLongObject *)n)) {
175175
PyErr_SetString(
176176
PyExc_ValueError,
177-
"ilog() argument must be positive");
177+
"ilog2() argument must be positive");
178178
Py_DECREF(n);
179179
return NULL;
180180
}
181181

182182
bits = _PyLong_NumBits(n);
183183
Py_DECREF(n);
184-
if (bits == (size_t)(-1)) {
184+
if (bits == -1) {
185185
return NULL;
186186
}
187-
return PyLong_FromSize_t(bits - 1);
187+
return PyLong_FromInt64(bits - 1);
188188
}
189189

190190

0 commit comments

Comments
 (0)
0