[Python-checkins] cpython (merge 3.3 -> 3.3): merge heads

eli.bendersky python-checkins at python.org
Thu Jan 24 16:17:49 CET 2013


http://hg.python.org/cpython/rev/3023849c0c15
changeset: 81687:3023849c0c15
branch: 3.3
parent: 81685:cce526a28f81
parent: 81682:999870e107f7
user: Eli Bendersky <eliben at gmail.com>
date: Thu Jan 24 07:17:05 2013 -0800
summary:
 merge heads
files:
 Lib/test/test_decimal.py | 14 ++++----------
 Modules/_decimal/_decimal.c | 8 +++++++-
 2 files changed, 11 insertions(+), 11 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
@@ -4971,22 +4971,16 @@
 def test_c_format(self):
 # Restricted input
 Decimal = C.Decimal
- InvalidOperation = C.InvalidOperation
- Rounded = C.Rounded
- localcontext = C.localcontext
 HAVE_CONFIG_64 = (C.MAX_PREC > 425000000)
 
 self.assertRaises(TypeError, Decimal(1).__format__, "=10.10", [], 9)
 self.assertRaises(TypeError, Decimal(1).__format__, "=10.10", 9)
 self.assertRaises(TypeError, Decimal(1).__format__, [])
 
- with localcontext() as c:
- c.traps[InvalidOperation] = True
- c.traps[Rounded] = True
- self.assertRaises(ValueError, Decimal(1).__format__, "<>=10.10")
- maxsize = 2**63-1 if HAVE_CONFIG_64 else 2**31-1
- self.assertRaises(InvalidOperation, Decimal("1.23456789").__format__,
- "=%d.1" % maxsize)
+ self.assertRaises(ValueError, Decimal(1).__format__, "<>=10.10")
+ maxsize = 2**63-1 if HAVE_CONFIG_64 else 2**31-1
+ self.assertRaises(ValueError, Decimal("1.23456789").__format__,
+ "=%d.1" % maxsize)
 
 def test_c_integral(self):
 Decimal = C.Decimal
diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c
--- a/Modules/_decimal/_decimal.c
+++ b/Modules/_decimal/_decimal.c
@@ -3222,7 +3222,13 @@
 
 decstring = mpd_qformat_spec(MPD(dec), &spec, CTX(context), &status);
 if (decstring == NULL) {
- dec_addstatus(context, status);
+ if (status & MPD_Malloc_error) {
+ PyErr_NoMemory();
+ }
+ else {
+ PyErr_SetString(PyExc_ValueError,
+ "format specification exceeds internal limits of _decimal");
+ }
 goto finish;
 }
 result = PyUnicode_DecodeUTF8(decstring, strlen(decstring), NULL);
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

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