-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setters of members with unsigned integer type and __index__() #115011
Labels
Comments
serhiy-storchaka
added a commit
to serhiy-storchaka/cpython
that referenced
this issue
Feb 5, 2024
… with unsigned integer type Setters for members with an unsigned integer type now support the same range of valid values for objects that has a __index__() method as for int. Previously, Py_T_UINT, Py_T_ULONG and Py_T_ULLONG did not support objects that has a __index__() method larger than LONG_MAX. Py_T_ULLONG did not support negative ints. Now it supports them and emits a RuntimeWarning.
serhiy-storchaka
added a commit
that referenced
this issue
Feb 11, 2024
…unsigned integer type (GH-115029) Setters for members with an unsigned integer type now support the same range of valid values for objects that has a __index__() method as for int. Previously, Py_T_UINT, Py_T_ULONG and Py_T_ULLONG did not support objects that has a __index__() method larger than LONG_MAX. Py_T_ULLONG did not support negative ints. Now it supports them and emits a RuntimeWarning.
serhiy-storchaka
added a commit
to serhiy-storchaka/cpython
that referenced
this issue
Feb 11, 2024
…members with unsigned integer type (pythonGH-115029) Setters for members with an unsigned integer type now support the same range of valid values for objects that has a __index__() method as for int. Previously, Py_T_UINT, Py_T_ULONG and Py_T_ULLONG did not support objects that has a __index__() method larger than LONG_MAX. Py_T_ULLONG did not support negative ints. Now it supports them and emits a RuntimeWarning. (cherry picked from commit d9d6909) Co-authored-by: Serhiy Storchaka <[email protected]>
serhiy-storchaka
added a commit
to serhiy-storchaka/cpython
that referenced
this issue
Feb 11, 2024
…members with unsigned integer type (pythonGH-115029) Setters for members with an unsigned integer type now support the same range of valid values for objects that has a __index__() method as for int. Previously, Py_T_UINT, Py_T_ULONG and Py_T_ULLONG did not support objects that has a __index__() method larger than LONG_MAX. Py_T_ULLONG did not support negative ints. Now it supports them and emits a RuntimeWarning. (cherry picked from commit d9d6909) Co-authored-by: Serhiy Storchaka <[email protected]>
serhiy-storchaka
added a commit
that referenced
this issue
Feb 11, 2024
…s with unsigned integer type (GH-115029) (GH-115294) Setters for members with an unsigned integer type now support the same range of valid values for objects that has a __index__() method as for int. Previously, Py_T_UINT, Py_T_ULONG and Py_T_ULLONG did not support objects that has a __index__() method larger than LONG_MAX. Py_T_ULLONG did not support negative ints. Now it supports them and emits a RuntimeWarning. (cherry picked from commit d9d6909)
serhiy-storchaka
added a commit
that referenced
this issue
Feb 11, 2024
…s with unsigned integer type (GH-115029) (GH-115295) Setters for members with an unsigned integer type now support the same range of valid values for objects that has a __index__() method as for int. Previously, Py_T_UINT, Py_T_ULONG and Py_T_ULLONG did not support objects that has a __index__() method larger than LONG_MAX. Py_T_ULLONG did not support negative ints. Now it supports them and emits a RuntimeWarning. (cherry picked from commit d9d6909)
fsc-eriker
pushed a commit
to fsc-eriker/cpython
that referenced
this issue
Feb 14, 2024
… with unsigned integer type (pythonGH-115029) Setters for members with an unsigned integer type now support the same range of valid values for objects that has a __index__() method as for int. Previously, Py_T_UINT, Py_T_ULONG and Py_T_ULLONG did not support objects that has a __index__() method larger than LONG_MAX. Py_T_ULLONG did not support negative ints. Now it supports them and emits a RuntimeWarning.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
isLONG_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 limitUINT_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 isLONG_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 becausePyLong_AsSsize_t()
does not support them.Linked PRs
The text was updated successfully, but these errors were encountered: