[Python-checkins] cpython (merge 3.3 -> default): Merge 3.3.

stefan.krah python-checkins at python.org
Sat Nov 10 23:32:41 CET 2012


http://hg.python.org/cpython/rev/5459cb9c5942
changeset: 80343:5459cb9c5942
parent: 80341:8c48eb0239ca
parent: 80342:2f35cdd1497b
user: Stefan Krah <skrah at bytereef.org>
date: Sat Nov 10 23:31:22 2012 +0100
summary:
 Merge 3.3.
files:
 Lib/test/test_decimal.py | 11 ++++++++++-
 Modules/_decimal/_decimal.c | 4 +++-
 2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py
--- a/Lib/test/test_decimal.py
+++ b/Lib/test/test_decimal.py
@@ -35,7 +35,7 @@
 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 @@
 # 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
diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c
--- a/Modules/_decimal/_decimal.c
+++ b/Modules/_decimal/_decimal.c
@@ -1892,7 +1892,9 @@
 Py_ssize_t j, len;
 int d;
 
- assert(PyUnicode_IS_READY(u));
+ if (PyUnicode_READY(u) == -1) {
+ return NULL;
+ }
 
 kind = PyUnicode_KIND(u);
 data = PyUnicode_DATA(u);
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /