Files
RustPython/crates
Luan Taraschi 9fd2ba8367 Compare complex with int exactly instead of through a float (#9180)
complex.__eq__ and __ne__ converted an int operand to f64 before
comparing, so a complex whose real part is the float nearest to a large
int compared equal to that int even when the values differ:
complex(2**53 + 1) == 2**53 + 1 returned True, while
float(2**53 + 1) == 2**53 + 1 returns False and the two objects hash
differently.

When the imaginary part is zero, compare the real part against the
exact integer with float_ops::eq_int, the helper float's own comparison
uses. This matches CPython, which hands an int operand to float's rich
comparison. test_complex.test_richcompare_boundaries now passes, so drop
its expectedFailure marker.

Assisted-by: Claude Code:claude-opus-5-5
2026-10-18 11:01:54 +09:00
..
2026-03-31 21:05:08 +09:00