You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
'_PyLong_NumBits': identifier not found in 3.13 #119336
While fixing pywin32 to let CI builds work in Python 3.13, the build process complained of not being able to find _PyLong_NumBits. All other Python versions in the CI built successfully.
I cannot make that call, but I made #119418 against 3.14 for now (it can be backported for 3.13 if that's what people decide). Eventually it seems like a good idea to make this public.
Activity
emmatyping commentedon May 22, 2024
In 5846924 Victor restored
_PyLong_Copy()_PyLong_FromDigits()_PyLong_New()_PyLong_Sign()It seems reasonable to include
_PyLong_NumBitsas well, since like the others there isn't a great replacement.clin1234 commentedon May 22, 2024
Will it be restored in the next beta 3.13 release, or will I have to wait until the first 3.14 alpha release?
pythongh-119336: Restore _PyLong_NumBits
emmatyping commentedon May 22, 2024
I cannot make that call, but I made #119418 against 3.14 for now (it can be backported for 3.13 if that's what people decide). Eventually it seems like a good idea to make this public.
vstinner commentedon May 28, 2024
You can modify pywin32 to call the
bit_length()method which returns a Python int object. Then if you need asize_t, you can callPyLong_AsSize_t.If this function is called by one project, we should consider making it public, rather than restoring the old private function.
clin1234 commentedon May 28, 2024
How would I access the built-in
bit_length()method within the C API?da-woods commentedon May 29, 2024
PyObject_CallMethod(obj, "bit_length", NULL)(Not taking a view on whether that justifies not restoring the function though)
vstinner commentedon May 29, 2024
A code search in PyPI top 7,500 projects found other projects:
pickle5 and zodbpickle contain copies of the Python source code, but MariaDB is a good usage example. So maybe it's worth it to add a function.
I created issue gh-119714: [C API] Add PyLong_GetNumBits() function.
vstinner commentedon May 29, 2024
@encukou also identified that panda3d uses it: https://github.com/panda3d/panda3d/blob/adb92428856853019583f398d27c5d34e44a9343/panda/src/putil/bitArray_ext.cxx#L28
gh-119336: Restore removed _PyLong_NumBits() function (#119418)
vstinner commentedon Jun 3, 2024
Function restored by commit e50fac9
pythongh-119336: Restore removed _PyLong_NumBits() function (pythonGH…
[3.13] gh-119336: Restore removed _PyLong_NumBits() function (GH-119418…
pythongh-119336: Restore removed _PyLong_NumBits() function (python#1…
pythongh-119336: Restore removed _PyLong_NumBits() function (python#1…