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 diff --git a/Misc/NEWS.d/next/macOS/2026-03-13-08-49-26.gh-issue-145902.UiPZUw.rst b/Misc/NEWS.d/next/macOS/2026-03-13-08-49-26.gh-issue-145902.UiPZUw.rst new file mode 100644 index 00000000000000..8208c4eb045f59 --- /dev/null +++ b/Misc/NEWS.d/next/macOS/2026-03-13-08-49-26.gh-issue-145902.UiPZUw.rst @@ -0,0 +1,2 @@ +Fix incorrect handling of division by zero so that Python consistently +raises ``ZeroDivisionError`` as expected.