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 — Deprecate accepting out of range values for unsigned integers in PyArg_Parse · Issue #132629 · python/cpython

Deprecate accepting out of range values for unsigned integers in PyArg_Parse #132629

New issue
Copy link
New issue
Copy link
Closed
Closed
Deprecate accepting out of range values for unsigned integers in PyArg_Parse#132629
Copy link
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedtopic-C-APItype-featureA feature request or enhancementA feature request or enhancement

Description

@serhiy-storchaka
serhiy-storchaka
opened on Apr 17, 2025
Issue body actions

Feature or enhancement

For unsigned integer formats (B, H, I, k, K) in PyArg_Parse, there is no overflow check. If the Python integer value is out of range of the corresponding C type, only the lowest bits are stored, and the higher bits are silently dropped. There are two reasons for this:

  • The signess of the C type accepted by the C API (like uid_t, etc) is not always known. We need to accept values that fit in corresponding both signed and unsigned C types.
  • Even if the type is unsigned, some small negative integers (casted to the unsigned tyep) can have special meaning. It is convenient if we can pass -1 instead of 0xffff_ffff or 0xffff_ffff_ffff_ffff, depending on platform.

But values that cannot be represented neither in unsigned not in signed C type, are obviously invalid. Silently accepting them can provoke bugs.

At first, I propose to emit a deprecation warning for such values. Later they will became errors.

Linked PRs

  • gh-132629: Deprecate acception out of range values for unsigned integers in PyArg_Parse #132630

Activity

  1. serhiy-storchaka
    added
    3.14bugs and security fixesbugs and security fixes
    topic-C-API
    type-featureA feature request or enhancementA feature request or enhancement
    on Apr 17, 2025
  2. serhiy-storchaka
    added a commit that references this issue on Apr 17, 2025

    pythongh-132629: Deprecate acception out of range values for unsigned…

    fbc7873
  3. picnixz
    added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    and removed
    3.14bugs and security fixesbugs and security fixes
    on Apr 17, 2025
  4. serhiy-storchaka
    added a commit that references this issue on Jul 13, 2025

    gh-132629: Deprecate accepting out-of-range values for unsigned integ…

    e18829a
  5. picnixz
    added a commit that references this issue on Jul 13, 2025

    pythongh-132629: Deprecate accepting out-of-range values for unsigned…

    1503249
  6. taegyunkim
    added a commit that references this issue on Aug 4, 2025

    pythongh-132629: Deprecate accepting out-of-range values for unsigned…

    a0ef472
  7. Agent-Hellboy
    added a commit that references this issue on Aug 19, 2025

    pythongh-132629: Deprecate accepting out-of-range values for unsigned…

    78576be
  8. StanFromIreland commented on Sep 11, 2025

    @StanFromIreland
    StanFromIreland
    on Sep 11, 2025
    Member
    More actions

    Deprecated in e18829a, is there anything left to do here?

  9. StanFromIreland
    added
    pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is provided
    on Sep 11, 2025
  10. hugovk
    closed this as completedon Oct 23, 2026
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

    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedtopic-C-APItype-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.