diff options
author | Stefan Krah <skrah@bytereef.org> | 2012-11-10 22:09:04 (GMT) |
---|---|---|
committer | Stefan Krah <skrah@bytereef.org> | 2012-11-10 22:09:04 (GMT) |
commit | 6e467049c68632dd58502a42b367100e99edb66b (patch) | |
tree | cce6a9d8eb315883c74671effbe7b8de6c59425a /Lib | |
parent | 6b0bdab4293684a2a7e47e8e8e70076c8670eb9b (diff) | |
download | cpython-6e467049c68632dd58502a42b367100e99edb66b.zip cpython-6e467049c68632dd58502a42b367100e99edb66b.tar.gz cpython-6e467049c68632dd58502a42b367100e99edb66b.tar.bz2 |
Accept Unicode legacy strings in the Decimal constructor.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_decimal.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py index dd4c73c..5195930 100644 --- a/Lib/test/test_decimal.py +++ b/Lib/test/test_decimal.py @@ -35,7 +35,7 @@ import locale from test.support import (run_unittest, run_doctest, is_resource_enabled, requires_IEEE_754) from test.support import (check_warnings, import_fresh_module, TestFailed, - run_with_locale) + run_with_locale, cpython_only) import random import time import warnings @@ -574,6 +574,15 @@ class ExplicitConstructionTest(unittest.TestCase): # embedded NUL self.assertRaises(InvalidOperation, Decimal, "12\u00003") + @cpython_only + def test_from_legacy_strings(self): + import _testcapi + Decimal = self.decimal.Decimal + context = self.decimal.Context() + + s = _testcapi.unicode_legacy_string('9.999999') + self.assertEqual(str(Decimal(s)), '9.999999') + self.assertEqual(str(context.create_decimal(s)), '9.999999') def test_explicit_from_tuples(self): Decimal = self.decimal.Decimal |