]> granicus.if.org Git - python/commitdiff
Backport bff16086f03b and bcaaaa00425b.
authorStefan Krah <skrah@bytereef.org>
Wed, 29 May 2013 17:14:17 +0000 (19:14 +0200)
committerStefan Krah <skrah@bytereef.org>
Wed, 29 May 2013 17:14:17 +0000 (19:14 +0200)
Lib/test/test_decimal.py
Modules/_decimal/_decimal.c

index 296939419c24fde5ecf9e93ab7205f0e3f7e4a12..50a9ad4362b6a6469bd9a84fa53492ad2d26b327 100644 (file)
@@ -5373,6 +5373,19 @@ class CWhitebox(unittest.TestCase):
             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,
index 98d49e6e0a96256b9fe8f36dacd57b967030306b..d3e394041f642e3b4c415484683b8419094a4e42 100644 (file)
@@ -4469,10 +4469,10 @@ _dec_hash(PyDecObject *v)
             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 @@ PyInit__decimal(void)
         }
 
         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 @@ PyInit__decimal(void)
             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));