Describe the bug
I have following new failure in the python-gmp CI tests:
________________________________ test_to_float _________________________________
x = 199506311688075838...7743047925967093760
@given(bigints())
@example(117529601297931785)
@example(1<<64)
@example(9007199254740993)
@example(10965857771245191)
@example(10<<10000)
@example((1<<53) + 1)
@example(1<<116)
@example(646541478744828163276576707651635923929979156076518566789121)
@example((0xfffffffffffff8<<(242*4)) + (1<<970))
@example(0xa<<10000)
def test_to_float(x):
mx = mpz(x)
try:
> fx = float(x)
^^^^^^^^
E OverflowError: int too large to convert to float
tests/test_mpz.py:951: OverflowError
During handling of the above exception, another exception occurred:
> ???
tests/test_mpz.py:5:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/opt/hostedtoolcache/GraalPy/25.1.3/x64/lib/python3.12/site-packages/hypothesis/core.py:1666: in _raise_to_user
raise the_error_hypothesis_found
tests/test_mpz.py:953: in test_to_float
pytest.raises(OverflowError, lambda: float(mx))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pytest.raises(OverflowError, lambda: float(mx))
^^^^^^^^^
E OverflowError: integer too large to convert to float
E Falsifying explicit example: test_to_float(
E x=0xa_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000,
E )
tests/test_mpz.py:953: OverflowError
Build log: https://github.com/diofant/python-gmp/actions/runs/28503793926/job/84487159175
The hypothesis thinks it found a falsifying example with x=0xa<<10000. The test checks that both for builtin integers and for the mpz type - conversion to floats raise a OverflowError. That seems to be the case:
Python 3.12.8 (Tue Jun 23 15:26:01 UTC 2026)
[Graal, Oracle GraalVM, Java 25.0.3 (amd64)] on 'linux'
Type "help", "copyright", "credits" or "license" for more information.
>>> from gmp import mpz
>>> m = 0xa<<10000
>>> mz = mpz(m)
>>> float(m)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: int too large to convert to float
>>> float(mz)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: integer too large to convert to float
I guess, the problem could be with hypothesis/pytest related patches for the GraalPy.
This test works successfully on older versions of the GraalPy or on other Python implementations. Also, it seems that change
pytest.raises(OverflowError, lambda: float(mx))
to
with pytest.raises(OverflowError):
float(mx)
fixes it (or at least reduces probability of a failure).
Operating system
Linux
CPU architecture
x86_64
GraalPy version
25.1.3
JDK version
No response
Context configuration
No response
Steps to reproduce
- Clone repo:
git clone git@github.com:diofant/python-gmp.git && cd python-gmp
- Build the project:
pip install --verbose .[tests] -Cbuild-dir=build -Csetup-args=-Dbuildtype=debug -Csetup-args=-Db_coverage=true
- Run full set of tests (you might want to add that
@example(0xa<<10000) to test_to_float(), to be sure):
N.B., I can't provide a simpler reproducer. E.g. without CI=1 or if I select just that specific test - it pass.
Expected behavior
No false alarm. Tests pass.
Stack trace
Additional context
No response
Describe the bug
I have following new failure in the python-gmp CI tests:
Build log: https://github.com/diofant/python-gmp/actions/runs/28503793926/job/84487159175
The hypothesis thinks it found a falsifying example with
x=0xa<<10000. The test checks that both for builtin integers and for the mpz type - conversion to floats raise a OverflowError. That seems to be the case:I guess, the problem could be with hypothesis/pytest related patches for the GraalPy.
This test works successfully on older versions of the GraalPy or on other Python implementations. Also, it seems that change
to
fixes it (or at least reduces probability of a failure).
Operating system
Linux
CPU architecture
x86_64
GraalPy version
25.1.3
JDK version
No response
Context configuration
No response
Steps to reproduce
@example(0xa<<10000)to test_to_float(), to be sure):N.B., I can't provide a simpler reproducer. E.g. without CI=1 or if I select just that specific test - it pass.
Expected behavior
No false alarm. Tests pass.
Stack trace
Additional context
No response