Title: [C API] Add PyLong_AsInt() public function · Issue #108444 · python/cpython · GitHub
Open Graph Title: [C API] Add PyLong_AsInt() public function · Issue #108444 · python/cpython
X Title: [C API] Add PyLong_AsInt() public function · Issue #108444 · python/cpython
Description: 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 priv...
Open Graph Description: 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 201...
X Description: 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 201...
Opengraph URL: https://github.com/python/cpython/issues/108444
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[C API] Add PyLong_AsInt() public function","articleBody":"# Feature or enhancement\n\n### Has this already been discussed elsewhere?\n\nNo response given\n\n### Links to previous discussion of this feature:\n\n_No response_\n\n### Proposal:\n\nThe _PyLong_AsInt() function was added in 2013 by commit 74f49ab28b91d3c23524356230feb2724ee9b23f. It was added a private function (``_Py``) prefix and it's not part of the limited C API.\n\nThis 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.\n\nUsing a private function is a bad practive: I removed many private functions from Python 3.13 C API, see issue #106320.\n\nI propose to add PyLong_AsInt() to the limited C API, add documentation and tests.\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-108445\n* gh-108458\n* gh-108459\n* gh-108461\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/vstinner","@type":"Person","name":"vstinner"},"datePublished":"2023-08-24T18:05:56.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/108444/cpython/issues/108444"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:0e9adaf3-d19b-01ab-86fd-626bab955b7f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AF64:2BBCB0:2272FBB:2D8BBDC:696B0DBC |
| html-safe-nonce | 00e162fe617d6c9f9e94cd0ab3e681ab9276279332297c910abf5aba49bd51c5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRjY0OjJCQkNCMDoyMjcyRkJCOjJEOEJCREM6Njk2QjBEQkMiLCJ2aXNpdG9yX2lkIjoiNDAwOTY3NTg5MDQyODE1MzI3NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ca0a247c05d9b6ef21532e6a1ebc305d52eca5fa37b1abe577c599409b7c4179 |
| hovercard-subject-tag | issue:1865644756 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/108444/issue_layout |
| twitter:image | https://opengraph.githubassets.com/77850d3c0acda4c4f96ba6dca92bc5d94142b3898680ea57bbb54c1f04ff3c10/python/cpython/issues/108444 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/77850d3c0acda4c4f96ba6dca92bc5d94142b3898680ea57bbb54c1f04ff3c10/python/cpython/issues/108444 |
| og:image:alt | 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 201... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | vstinner |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width