diff --git a/gmp.c b/gmp.c index 3422350e..2a6221e6 100644 --- a/gmp.c +++ b/gmp.c @@ -723,7 +723,7 @@ richcompare(PyObject *self, PyObject *other, int op) fallback: Py_RETURN_NOTIMPLEMENTED; numbers: - self = to_float(self); + self = MPZ_to_int((MPZ_Object *)self); if (!self) { return NULL; /* LCOV_EXCL_LINE */ } diff --git a/tests/test_mpz.py b/tests/test_mpz.py index fad45e7a..893af4ec 100644 --- a/tests/test_mpz.py +++ b/tests/test_mpz.py @@ -343,6 +343,7 @@ def test_repr(x): @given(bigints(), floats(allow_nan=False)) +@example(9007199254740993, 9007199254740992.0) def test_richcompare_mixed(x, y): mx = mpz(x) for op in [operator.eq, operator.ne, operator.lt, operator.le, @@ -357,10 +358,6 @@ def test_richcompare_errors(): mx > 1j with pytest.raises(TypeError): mx > object() - with pytest.raises(OverflowError): - mpz(10**1000) < 1.1 - with pytest.raises(OverflowError): - mpz(10**1000) > 1.1 def test_hash_caching():