bpo-23975: Correct conversion of Rational’s to float by skirpichev · Pull Request #25619 · python/cpython (original) (raw)

Hmm, unfortunately, there is a silent type-cast. I can adjust the test, but may be it does make sense to add

diff --git a/Lib/fractions.py b/Lib/fractions.py index f9ac882ec0..4a153ee8e3 100644 --- a/Lib/fractions.py +++ b/Lib/fractions.py @@ -143,6 +143,10 @@ def new(cls, numerator=0, denominator=None, *, _normalize=True): elif type(numerator) is int is type(denominator): pass # very normal case

... or I can just "fix" type of private _numerator/denominator properties in the test by monkey patching.