Skip to content

sys.set_int_max_str_digits ValueError Message is Inaccurate #127238

Closed

Description

@amhamor

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

Activity

  1. ZeroIntensity commented on Nov 24, 2024

    @ZeroIntensity
    Member
  2. terryjreedy commented on Nov 25, 2024

    @terryjreedy
    Member

    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.)

  3. added a commit that references this issue on Nov 25, 2024
  4. skirpichev commented on Nov 25, 2024

    @skirpichev
    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

  5. added a commit that references this issue on Nov 25, 2024
  6. added a commit that references this issue on Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions