[pypy-commit] pypy py3.6: fix test_decimal

cfbolz pypy.commits at gmail.com
Sun Feb 24 09:10:01 EST 2019


Author: Carl Friedrich Bolz-Tereick <cfbolz at gmx.de>
Branch: py3.6
Changeset: r96145:3b7015c3581a
Date: 2019-02-24 15:06 +0100
http://bitbucket.org/pypy/pypy/changeset/3b7015c3581a/

Log:	fix test_decimal

diff --git a/lib_pypy/_decimal.py b/lib_pypy/_decimal.py
--- a/lib_pypy/_decimal.py
+++ b/lib_pypy/_decimal.py
@@ -1295,6 +1295,13 @@
             raise RuntimeError("Invalid error flag", trapped)
 
     def create_decimal(self, num="0"):
+        """Creates a new Decimal instance but using self as context.
+
+        This method implements the to-number operation of the
+        IBM Decimal specification."""
+
+        if isinstance(num, str) and (num != num.strip() or '_' in num):
+            num = '' # empty string triggers ConversionSyntax
         return Decimal._from_object(num, self, exact=False)
 
     def create_decimal_from_float(self, f):


More information about the pypy-commit mailing list