astroid icon indicating copy to clipboard operation
astroid copied to clipboard

ValueError when stringifying large int in AstroidTypeError message

Open correctmost opened this issue 7 months ago • 0 comments

Steps to reproduce

The following code triggers a ValueError in astroid:

a,=7**10000
a.B

This bug was discovered by OSS-Fuzz (an OSS-Fuzz bug report was not filed for it due to infrastructure issues).

Current behavior

Traceback (most recent call last):
  File "pylint/pylint/checkers/utils.py", line 1364, in safe_infer
    value = next(infer_gen)
            ^^^^^^^^^^^^^^^
  File "astroid/astroid/nodes/node_ng.py", line 164, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "astroid/astroid/decorators.py", line 81, in inner
    yield next(generator)
          ^^^^^^^^^^^^^^^
  File "astroid/astroid/decorators.py", line 44, in wrapped
    for res in _func(node, context, **kwargs):
  File "astroid/astroid/bases.py", line 184, in _infer_stmts
    for inf in stmt.infer(context=context):
  File "astroid/astroid/nodes/node_ng.py", line 164, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "astroid/astroid/decorators.py", line 81, in inner
    yield next(generator)
          ^^^^^^^^^^^^^^^
  File "astroid/astroid/decorators.py", line 44, in wrapped
    for res in _func(node, context, **kwargs):
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "astroid/astroid/nodes/node_classes.py", line 451, in _infer
    stmts = list(self.assigned_stmts(context=context))
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "astroid/astroid/decorators.py", line 81, in inner
    yield next(generator)
          ^^^^^^^^^^^^^^^
  File "astroid/astroid/protocols.py", line 456, in assign_assigned_stmts
    yield from _resolve_assignment_parts(
  File "astroid/astroid/protocols.py", line 497, in _resolve_assignment_parts
    assigned = part.getitem(index_node, context)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "astroid/astroid/nodes/node_classes.py", line 2136, in getitem
    raise AstroidTypeError(f"{self!r} (value={self.value})")
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: Exceeds the limit (4300 digits) for integer string conversion; use sys.set_int_max_str_digits() to increase the limit

Expected behavior

No crash

Version

8cb239f3f41453

correctmost avatar Jul 22 '25 03:07 correctmost