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 — Setters of members with unsigned integer type and __index__() · Issue #115011 · python/cpython

Setters of members with unsigned integer type and __index__() #115011

New issue
Copy link
New issue
Copy link
Closed
Closed
Setters of members with unsigned integer type and __index__()#115011
Copy link
Assignees
serhiy-storchaka
Labels
topic-C-API

Description

@serhiy-storchaka
serhiy-storchaka
opened on Feb 4, 2024
Issue body actions

Yet one strange thing about member setters with unsigned integer type is that they support different ranges for int and int-like objects (objects with the __index__() method).

For Py_T_ULONG the range for int is LONG_MIN-ULONG_MAX, but for indexes it is smaller: LONG_MIN-LONG_MAX.

The same is for Py_T_UINT, except that the maximal hard limit for index LONG_MAX can be larger than the maximal safe limit UINT_MAX, depending on platform, so on some platforms it may be lesser issue.

Py_T_ULLONG is even more limited. The range for int is 0-ULLONG_MAX (negatives not allowed!), and the range for indexes is LONG_MIN-LONG_MAX, which includes negatives, bat has much lesser upper limit. It is a remnant of dark old times, when Python had two not yet completely compatible integer types.

Py_T_PYSSIZET does not support __index__() at all. It is because PyLong_AsSsize_t() does not support them.

Linked PRs

  • gh-115011: Improve support of __index__() in setters of members with unsigned integer type #115029
  • [3.12] gh-115011: Improve support of __index__() in setters of members with unsigned integer type (GH-115029) #115294
  • [3.11] gh-115011: Improve support of __index__() in setters of members with unsigned integer type (GH-115029) #115295

Activity

  1. serhiy-storchaka
    added
    topic-C-API
    on Feb 4, 2024
  2. serhiy-storchaka
    self-assigned this
    on Feb 4, 2024
  3. serhiy-storchaka
    added 4 commits that reference this issue on Feb 5, 2024

    pythongh-115011: Improve support of __index__() in setters of members…

    f0d110c

    gh-115011: Improve support of __index__() in setters of members with …

    d9d6909

    [3.12] pythongh-115011: Improve support of __index__() in setters of …

    159eff5

    [3.11] pythongh-115011: Improve support of __index__() in setters of …

    1f6b297
  4. serhiy-storchaka
    closed this as completedon Feb 11, 2024
  5. serhiy-storchaka
    added 2 commits that reference this issue on Feb 11, 2024

    [3.12] gh-115011: Improve support of __index__() in setters of member…

    d8346d6

    [3.11] gh-115011: Improve support of __index__() in setters of member…

    7273a58
  6. fsc-eriker
    added a commit that references this issue on Feb 14, 2024

    pythongh-115011: Improve support of __index__() in setters of members…

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

Metadata

Metadata

Assignees

  • @serhiy-storchaka
    serhiy-storchaka

Labels

topic-C-API

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.