Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use new helper in from_float/Decimal
  • Loading branch information
skirpichev committed Feb 11, 2023
commit 9e66b5a1c11ba432518acc23b17a7cf447870989
4 changes: 2 additions & 2 deletions Lib/fractions.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def from_float(cls, f):
elif not isinstance(f, float):
raise TypeError("%s.from_float() only takes floats, not %r (%s)" %
(cls.__name__, f, type(f).__name__))
return cls(*f.as_integer_ratio())
return cls._from_pair(*f.as_integer_ratio())

@classmethod
def from_decimal(cls, dec):
Expand All @@ -312,7 +312,7 @@ def from_decimal(cls, dec):
raise TypeError(
"%s.from_decimal() only takes Decimals, not %r (%s)" %
(cls.__name__, dec, type(dec).__name__))
return cls(*dec.as_integer_ratio())
return cls._from_pair(*dec.as_integer_ratio())

@classmethod
def _from_pair(cls, numerator, denominator, /):
Comment thread
skirpichev marked this conversation as resolved.
Outdated
Expand Down