Author: Armin Rigo <ar...@tunes.org> Branch: py3.5 Changeset: r90043:6f94d4627b17 Date: 2017-02-11 14:36 +0100 http://bitbucket.org/pypy/pypy/changeset/6f94d4627b17/
Log: fix diff --git a/lib_pypy/_decimal.py b/lib_pypy/_decimal.py --- a/lib_pypy/_decimal.py +++ b/lib_pypy/_decimal.py @@ -329,7 +329,14 @@ @classmethod def from_float(cls, value): - return cls._from_float(value, getcontext(), exact=True) + # note: if 'cls' is a subclass of Decimal and 'value' is an int, + # this will call cls(Decimal('42')) whereas _pydecimal.py will + # call cls(42). This is like CPython's _decimal module. + result = cls._from_float(value, getcontext(), exact=True) + if cls is Decimal: + return result + else: + return cls(result) @classmethod def _from_float(cls, value, context, exact=True): _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit