Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
Labels
@serhiy-storchaka

Description

@serhiy-storchaka

Feature or enhancement

For unsigned integer formats (B,H,I,k,K) inPyArg_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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp