[Python-checkins] cpython (3.3): Backport bff16086f03b and bcaaaa00425b.

stefan.krah python-checkins at python.org
Wed May 29 19:16:08 CEST 2013


http://hg.python.org/cpython/rev/8a77d7019559
changeset:   83979:8a77d7019559
branch:      3.3
parent:      83974:9156c663d6aa
user:        Stefan Krah <skrah at bytereef.org>
date:        Wed May 29 19:14:17 2013 +0200
summary:
  Backport bff16086f03b and bcaaaa00425b.

files:
  Lib/test/test_decimal.py    |  13 +++++++++++++
  Modules/_decimal/_decimal.c |  10 +++++-----
  2 files changed, 18 insertions(+), 5 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
@@ -5373,6 +5373,19 @@
             x = (1, (0, 1), "N")
             self.assertEqual(str(Decimal(x)), '-sNaN1')
 
+    def test_sizeof(self):
+        Decimal = C.Decimal
+        HAVE_CONFIG_64 = (C.MAX_PREC > 425000000)
+
+        self.assertGreater(Decimal(0).__sizeof__(), 0)
+        if HAVE_CONFIG_64:
+            x = Decimal(10**(19*24)).__sizeof__()
+            y = Decimal(10**(19*25)).__sizeof__()
+            self.assertEqual(y, x+8)
+        else:
+            x = Decimal(10**(9*24)).__sizeof__()
+            y = Decimal(10**(9*25)).__sizeof__()
+            self.assertEqual(y, x+4)
 
 all_tests = [
   CExplicitConstructionTest, PyExplicitConstructionTest,
diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c
--- a/Modules/_decimal/_decimal.c
+++ b/Modules/_decimal/_decimal.c
@@ -4469,10 +4469,10 @@
             goto malloc_error;
         }
         else {
-            PyErr_SetString(PyExc_RuntimeError,
-                "dec_hash: internal error: please report");
+            PyErr_SetString(PyExc_RuntimeError, /* GCOV_NOT_REACHED */
+                "dec_hash: internal error: please report"); /* GCOV_NOT_REACHED */
         }
-        result = -1;
+        result = -1; /* GCOV_NOT_REACHED */
     }
 
 
@@ -5623,7 +5623,7 @@
         }
 
         if (base == NULL) {
-            goto error;
+            goto error; /* GCOV_NOT_REACHED */
         }
 
         ASSIGN_PTR(cm->ex, PyErr_NewException((char *)cm->fqname, base, NULL));
@@ -5655,7 +5655,7 @@
             base = PyTuple_Pack(1, signal_map[0].ex);
         }
         if (base == NULL) {
-            goto error;
+            goto error; /* GCOV_NOT_REACHED */
         }
 
         ASSIGN_PTR(cm->ex, PyErr_NewException((char *)cm->fqname, base, NULL));

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list