Skip to content

ValueError in int <-> str conversions #3

@tueda

Description

@tueda

In complicated systems, it is often the case that fixing your bug causes a new bug for others. The latest CPython bugfix releases have introduced a breaking change in conversions between large integers and strings. So far, no alternate API has been provided except for changing global settings (which is not appropriate for libraries).

There are at least 3 places in this library affected by this change.

self._raw = _RawPolynomial(str(value))

python -c 'import donuts; donuts.Polynomial(10**4300)'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.10/site-packages/donuts/poly.py", line 74, in __init__
    self._raw = _RawPolynomial(str(value))
ValueError: Exceeds the limit (4300) for integer string conversion

return int(str(self))

python -c 'import donuts; (donuts.Polynomial(10)**4300).as_integer'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.10/site-packages/donuts/poly.py", line 266, in as_integer
    return int(str(self))
ValueError: Exceeds the limit (4300) for integer string conversion: value has 4301 digits

self._raw = _RawRationalFunction(str(numerator))

python -c 'import donuts; donuts.RationalFunction(10**4300)'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.10/site-packages/donuts/rat.py", line 64, in __init__
    self._raw = _RawRationalFunction(str(numerator))
ValueError: Exceeds the limit (4300) for integer string conversion

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions