This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: sys.maxsize returns incorrect docstring.
Type: Stage: resolved
Components: Library (Lib) Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: akash0x53, steven.daprano, xtreak
Priority: normal Keywords:

Created on 2019-09-18 11:25 by akash0x53, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (4)
msg352716 - (view) Author: Akash Shende (akash0x53) * Date: 2019-09-18 11:25
>>> import sys
>>> print(sys.maxsize.__doc__)
int([x]) -> integer
int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments
are given.  If x is a number, return x.__int__().  For floating point
numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string,
bytes, or bytearray instance representing an integer literal in the
given base.  The literal can be preceded by '+' or '-' and be surrounded
by whitespace.  The base defaults to 10.  Valid bases are 0 and 2-36.
Base 0 means to interpret the base from the string as an integer literal.
>>> int('0b100', base=0)
4
msg352717 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2019-09-18 11:36
sys.maxsize returns an integer so essentially sys.maxsize.__doc__ is giving docs for int.__doc__. help(sys) to get to maxsize would help.

maxsize -- the largest supported length of containers.


python3
Python 3.8.0b4 (v3.8.0b4:d93605de72, Aug 29 2019, 21:47:47)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.maxsize)
9223372036854775807
>>> print(sys.maxsize.__doc__)
int([x]) -> integer
int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments
are given.  If x is a number, return x.__int__().  For floating point
numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string,
bytes, or bytearray instance representing an integer literal in the
given base.  The literal can be preceded by '+' or '-' and be surrounded
by whitespace.  The base defaults to 10.  Valid bases are 0 and 2-36.
Base 0 means to interpret the base from the string as an integer literal.
>>> int('0b100', base=0)
4


>>> print(int.__doc__)
int([x]) -> integer
int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments
are given.  If x is a number, return x.__int__().  For floating point
numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string,
bytes, or bytearray instance representing an integer literal in the
given base.  The literal can be preceded by '+' or '-' and be surrounded
by whitespace.  The base defaults to 10.  Valid bases are 0 and 2-36.
Base 0 means to interpret the base from the string as an integer literal.
>>> int('0b100', base=0)
4
msg352718 - (view) Author: Akash Shende (akash0x53) * Date: 2019-09-18 11:38
Yes. I checked that. Same for sys.maxunicode
msg352719 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2019-09-18 12:08
This is not a bug. ``sys.maxsize`` is just an int instance, and it has no docstring itself. When you look up ``sys.maxsize.__doc__``, or call ``help(sys.maxsize)``, the ordinary inheritance rules apply and you get the class docstring.

There is nothing magical about ``sys.maxsize``. You will get the same result for ``help(2147483647)`` or ``help(1234)`` or any other int. So you are getting the correct docstring, the one which belongs to the class.

I'm going to close this as "not a bug", but if you believe that you have a good reason to treat this as a bug, please reply. If your argument is convincing, we can re-open the ticket.
History
Date User Action Args
2022-04-11 14:59:20adminsetgithub: 82394
2019-09-18 12:08:02steven.dapranosetstatus: open -> closed

nosy: + steven.daprano
messages: + msg352719

resolution: not a bug
stage: resolved
2019-09-18 11:38:18akash0x53setmessages: + msg352718
2019-09-18 11:36:03xtreaksetnosy: + xtreak
messages: + msg352717
2019-09-18 11:25:21akash0x53create