From 9ea2aa4c1726dd218404c25e6ca2d501b5b9aa47 Mon Sep 17 00:00:00 2001 From: PB <129307305+pb21314@users.noreply.github.com> Date: Wed, 11 Mar 2026 10:40:26 +0100 Subject: [PATCH] Set denominator 1 Change default denominator from None to 1 in __new__ method --- Lib/fractions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/fractions.py b/Lib/fractions.py index c1b12e7a1c091c..a4bcb825017c49 100644 --- a/Lib/fractions.py +++ b/Lib/fractions.py @@ -203,7 +203,7 @@ class Fraction(numbers.Rational): __slots__ = ('_numerator', '_denominator') # We're immutable, so use __new__ not __init__ - def __new__(cls, numerator=0, denominator=None): + def __new__(cls, numerator=0, denominator=1): """Constructs a Rational. Takes a string like '3/2' or '1.5', another Rational instance, a