-
-
Notifications
You must be signed in to change notification settings - Fork 31k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[C API] Add PyLong_AsInt() public function #108444
Labels
type-feature
A feature request or enhancement
Comments
vstinner
added a commit
to vstinner/cpython
that referenced
this issue
Aug 24, 2023
* Rename _PyLong_AsInt() to PyLong_AsInt(). * Add documentation. * Add test. * For now, keep _PyLong_AsInt() as an alias to PyLong_AsInt().
vstinner
added a commit
to vstinner/cpython
that referenced
this issue
Aug 24, 2023
* Rename _PyLong_AsInt() to PyLong_AsInt(). * Add documentation. * Add test. * For now, keep _PyLong_AsInt() as an alias to PyLong_AsInt().
vstinner
added a commit
to vstinner/cpython
that referenced
this issue
Aug 24, 2023
* Rename _PyLong_AsInt() to PyLong_AsInt(). * Add documentation. * Add test. * For now, keep _PyLong_AsInt() as an alias to PyLong_AsInt().
vstinner
added a commit
that referenced
this issue
Aug 24, 2023
* Rename _PyLong_AsInt() to PyLong_AsInt(). * Add documentation. * Add test. * For now, keep _PyLong_AsInt() as an alias to PyLong_AsInt().
vstinner
added a commit
to vstinner/cpython
that referenced
this issue
Aug 24, 2023
Argument Clinic now uses the new public PyLong_AsInt(), rather than the old name _PyLong_AsInt().
vstinner
added a commit
to vstinner/cpython
that referenced
this issue
Aug 24, 2023
Change generated by the command: sed -i -e 's!_PyLong_AsInt!PyLong_AsInt!g' \ $(find -name "*.c" -o -name "*.h")
vstinner
added a commit
to vstinner/cpython
that referenced
this issue
Aug 24, 2023
Change generated by the command: sed -i -e 's!_PyLong_AsInt!PyLong_AsInt!g' \ $(find -name "*.c" -o -name "*.h")
vstinner
added a commit
that referenced
this issue
Aug 24, 2023
Argument Clinic now uses the new public PyLong_AsInt(), rather than the old name _PyLong_AsInt().
vstinner
added a commit
that referenced
this issue
Aug 24, 2023
Change generated by the command: sed -i -e 's!_PyLong_AsInt!PyLong_AsInt!g' \ $(find -name "*.c" -o -name "*.h")
vstinner
added a commit
to vstinner/cpython
that referenced
this issue
Aug 24, 2023
* Update Parser/asdl_c.py to regenerate Python/Python-ast.c. * Remove _PyLong_AsInt() alias to PyLong_AsInt().
vstinner
added a commit
that referenced
this issue
Aug 25, 2023
* Update Parser/asdl_c.py to regenerate Python/Python-ast.c. * Remove _PyLong_AsInt() alias to PyLong_AsInt().
Function added by be436e0 I also added the function to pythoncapi-compat: python/pythoncapi-compat@8109811 |
mikelolasagasti
added a commit
to mikelolasagasti/pyzstd
that referenced
this issue
Jun 14, 2024
The new public function PyLong_AsInt() has been introduced as part of python/cpython#108444 which renames the internal _PyLong_AsInt() to PyLong_AsInt(). Fixes Rogdham#13 Signed-off-by: Mikel Olasagasti Uranga <mikel@olasagasti.info>
mikelolasagasti
added a commit
to mikelolasagasti/pyzstd
that referenced
this issue
Jun 14, 2024
The new public function `PyLong_AsInt()` has been introduced as part of python/cpython#108444, which renames the internal `_PyLong_AsInt()` to `PyLong_AsInt()`. This change updates the code to use the new public API while maintaining compatibility with Python versions earlier than 3.13. Fixes Rogdham#13 Signed-off-by: Mikel Olasagasti Uranga <mikel@olasagasti.info>
Rogdham
pushed a commit
to mikelolasagasti/pyzstd
that referenced
this issue
Jun 16, 2024
Context in python/cpython#108444 Signed-off-by: Mikel Olasagasti Uranga <mikel@olasagasti.info>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Feature or enhancement
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response
Proposal:
The _PyLong_AsInt() function was added in 2013 by commit 74f49ab. It was added a private function (
_Py
) prefix and it's not part of the limited C API.This function is widely used in the Python code base which means that it's useful. Casting PyLong_AsLong() to
int
and then checking for overflow is error prone, it requires to raise the right exception.Using a private function is a bad practive: I removed many private functions from Python 3.13 C API, see issue #106320.
I propose to add PyLong_AsInt() to the limited C API, add documentation and tests.
Linked PRs
The text was updated successfully, but these errors were encountered: