GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [C API] Add PyLong_AsInt() public function · Issue #108444 · python/cpython

[C API] Add PyLong_AsInt() public function #108444

New issue
Copy link
New issue
Copy link
Closed
Closed
[C API] Add PyLong_AsInt() public function#108444
Copy link
Labels
type-featureA feature request or enhancementA feature request or enhancement

Description

@vstinner
vstinner
opened on Aug 24, 2023
Issue body actions

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

  • gh-108444: Add PyLong_AsInt() public function #108445
  • gh-108444: Argument Clinic uses PyLong_AsInt() #108458
  • gh-108444: Replace _PyLong_AsInt() with PyLong_AsInt() #108459
  • gh-108444: Remove _PyLong_AsInt() function #108461

Activity

  1. vstinner
    added
    type-featureA feature request or enhancementA feature request or enhancement
    on Aug 24, 2023
  2. vstinner
    added 11 commits that reference this issue on Aug 24, 2023

    pythongh-108444: Add PyLong_AsInt() public function

    88ca411

    pythongh-108444: Add PyLong_AsInt() public function

    c8c7686

    pythongh-108444: Add PyLong_AsInt() public function

    3a79210

    gh-108444: Add PyLong_AsInt() public function (#108445)

    be436e0

    pythongh-108444: Argument Clinic uses PyLong_AsInt()

    100c99d

    pythongh-108444: Replace _PyLong_AsInt() with PyLong_AsInt()

    61a9192

    pythongh-108444: Replace _PyLong_AsInt() with PyLong_AsInt()

    1dd3358

    gh-108444: Argument Clinic uses PyLong_AsInt() (#108458)

    4e5a728

    gh-108444: Replace _PyLong_AsInt() with PyLong_AsInt() (#108459)

    b32d4ca

    pythongh-108444: Remove _PyLong_AsInt() function

    a9d062c

    gh-108444: Remove _PyLong_AsInt() function (#108461)

    e59a952
  3. vstinner commented on Aug 25, 2023

    @vstinner
    vstinner
    on Aug 25, 2023
    MemberAuthor
    More actions

    Function added by be436e0

    I also added the function to pythoncapi-compat: python/pythoncapi-compat@8109811

  4. vstinner
    closed this as completedon Aug 25, 2023
  5. mikelolasagasti
    added 2 commits that reference this issue on Jun 14, 2024

    Replace _PyLong_AsInt() with PyLong_AsInt()

    d4c83a9

    Replace _PyLong_AsInt() with PyLong_AsInt() for Python 3.13+

    2c394fb
  6. Rogdham
    added a commit that references this issue on Jun 16, 2024

    chore: replace _PyLong_AsInt() with PyLong_AsInt()

    fb8efdd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-featureA feature request or enhancementA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.