Skip to content
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

sys.set_int_max_str_digits ValueError Message is Inaccurate #127238

Closed
amhamor opened this issue Nov 24, 2024 · 3 comments
Closed

sys.set_int_max_str_digits ValueError Message is Inaccurate #127238

amhamor opened this issue Nov 24, 2024 · 3 comments
Labels
docs Documentation in the Doc dir

Comments

@amhamor
Copy link

amhamor commented Nov 24, 2024

The sys.set_int_max_str_digits ValueError message is shown to be inaccurate in the following Python interpreter execution sequence:

>>> import sys
>>> sys.set_int_max_str_digits(maxdigits=639)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: maxdigits must be 0 or larger than 640
>>> sys.set_int_max_str_digits(maxdigits=640)
>>>

The sys.set_int_max_str_digits ValueError message states that "maxdigits" must be larger than "640." However, "sys.set_int_max_str_digits(maxdigits=640)" is a valid statement for Python to execute. Because argument "640" is valid for built-in function "sys.set_int_max_str_digits" and 640 is not larger than 640, this results in a discrepancy between what the ValueError message states as true and what is actually true.

Linked PRs

@amhamor amhamor added the docs Documentation in the Doc dir label Nov 24, 2024
@ZeroIntensity
Copy link
Member

cc @skirpichev

@terryjreedy
Copy link
Member

terryjreedy commented Nov 25, 2024

Passing 639 raises the ValueError, so 640 is the lower limit as documented: "The lowest limit that can be configured is 640 digits as provided in sys.int_info.str_digits_check_threshold. Indeed (EDITED)

>>> sys.int_info.str_digits_check_threshold 
640)

So, /larger than/at least/ in the error message, wherever it lives. (I am guessing that 640 = 8 lines of 80 digits.)

skirpichev added a commit to skirpichev/cpython that referenced this issue Nov 25, 2024
Now it's correct and closer to Python/initconfig.c
@skirpichev
Copy link
Member

I am guessing that 640 = 8 lines of 80 digits.

I would guess it's just a joke, referring to other famous quote (or to the myth about...) :D In Include/internal/pycore_long.h we have "640 digits should be enough for anyone." - gps

So, /larger than/at least/ in the error message

Here is a small pr, doing something like that: #127241

terryjreedy pushed a commit that referenced this issue Nov 25, 2024
…7241)

Now it's correct and closer to Python/initconfig.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
Status: Todo
Development

No branches or pull requests

4 participants