From c7d3358582f9726875dcf08c460b082d5e106609 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Wed, 14 Jun 2023 01:13:52 +0300 Subject: [PATCH] Update numbers from Python 3.11 --- Lib/numbers.py | 12 ++++++++---- Lib/test/test_numeric_tower.py | 2 -- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Lib/numbers.py b/Lib/numbers.py index 7eedc63ec..0985dd85f 100644 --- a/Lib/numbers.py +++ b/Lib/numbers.py @@ -33,9 +33,9 @@ class Complex(Number): """Complex defines the operations that work on the builtin complex type. In short, those are: a conversion to complex, .real, .imag, +, -, - *, /, abs(), .conjugate, ==, and !=. + *, /, **, abs(), .conjugate, ==, and !=. - If it is given heterogenous arguments, and doesn't have special + If it is given heterogeneous arguments, and doesn't have special knowledge about them, it should fall back to the builtin complex type as described below. """ @@ -288,11 +288,15 @@ class Rational(Real): so that ratios of huge integers convert without overflowing. """ - return self.numerator / self.denominator + return int(self.numerator) / int(self.denominator) class Integral(Rational): - """Integral adds a conversion to int and the bit-string operations.""" + """Integral adds methods that work on integral numbers. + + In short, these are conversion to int, pow with modulus, and the + bit-string operations. + """ __slots__ = () diff --git a/Lib/test/test_numeric_tower.py b/Lib/test/test_numeric_tower.py index 6441255ec..9cd85e136 100644 --- a/Lib/test/test_numeric_tower.py +++ b/Lib/test/test_numeric_tower.py @@ -134,8 +134,6 @@ class HashTest(unittest.TestCase): self.check_equal_hash(D('12300.00'), D(12300)) self.check_equal_hash(D('12300.000'), D(12300)) - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_fractions(self): # check special case for fractions where either the numerator # or the denominator is a multiple of _PyHASH_MODULUS