MCPcopy Index your code
hub / github.com/RustPython/RustPython / _convert_other

Function _convert_other

Lib/_pydecimal.py:5991–6008  ·  view source on GitHub ↗

Convert other to Decimal. Verifies that it's ok to use in an implicit construction. If allow_float is true, allow conversion from float; this is used in the comparison methods (__eq__ and friends).

(other, raiseit=False, allow_float=False)

Source from the content-addressed store, hash-verified

5989##### Helper Functions ####################################################
5990
5991def _convert_other(other, raiseit=False, allow_float=False):
5992 """Convert other to Decimal.
5993
5994 Verifies that it's ok to use in an implicit construction.
5995 If allow_float is true, allow conversion from float; this
5996 is used in the comparison methods (__eq__ and friends).
5997
5998 """
5999 if isinstance(other, Decimal):
6000 return other
6001 if isinstance(other, int):
6002 return Decimal(other)
6003 if allow_float and isinstance(other, float):
6004 return Decimal.from_float(other)
6005
6006 if raiseit:
6007 raise TypeError("Unable to convert %s to Decimal" % other)
6008 return NotImplemented
6009
6010def _convert_for_comparison(self, other, equality_op=False):
6011 """Given a Decimal instance self and a Python object other, return

Callers 15

compareMethod · 0.85
__add__Method · 0.85
__sub__Method · 0.85
__rsub__Method · 0.85
__mul__Method · 0.85
__truediv__Method · 0.85
__rtruediv__Method · 0.85
__divmod__Method · 0.85
__rdivmod__Method · 0.85
__mod__Method · 0.85
__rmod__Method · 0.85
remainder_nearMethod · 0.85

Calls 3

isinstanceFunction · 0.85
DecimalClass · 0.85
from_floatMethod · 0.45

Tested by

no test coverage detected