Closed
Description
Bug report
Bug description:
The following code
>>> import sys; sys.set_int_max_str_digits(0); 10**10000
works in 3.11 but hangs in 3.12. Interrupting it gives this backtrace:
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.12/_pylong.py", line 85, in int_to_decimal_string
return str(int_to_decimal(n))
^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/_pylong.py", line 77, in int_to_decimal
result = inner(n, n.bit_length())
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/_pylong.py", line 64, in inner
return inner(lo, w2) + inner(hi, w - w2) * w2pow(w2)
^^^^^^^^^^^^^
File "/usr/lib/python3.12/_pylong.py", line 64, in inner
return inner(lo, w2) + inner(hi, w - w2) * w2pow(w2)
^^^^^^^^^^^^^
File "/usr/lib/python3.12/_pylong.py", line 64, in inner
return inner(lo, w2) + inner(hi, w - w2) * w2pow(w2)
^^^^^^^^^^^^^
[Previous line repeated 6 more times]
File "/usr/lib/python3.12/_pylong.py", line 45, in w2pow
result = D2**w
~~^^~
File "/usr/lib/python3.12/_pydecimal.py", line 2339, in __pow__
ans = self._power_exact(other, context.prec + 1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/_pydecimal.py", line 2187, in _power_exact
if xc > 10**p:
~~^^~
KeyboardInterrupt
CPython versions tested on:
3.11, 3.12
Operating systems tested on:
Linux
Linked PRs
- gh-118164: Break a loop between _pydecimal and _pylong and optimize int to str conversion #118483
- gh-118164: str(10**10000) hangs if the C _decimal module is missing #118503
- [3.12] gh-118164: str(10**10000) hangs if the C _decimal module is missing (GH-118503) #118584
- [3.12] gh-118164: Break a loop between _pydecimal and _pylong and optimize int to str conversion (GH-118483) #118590