]> granicus.if.org Git - python/commitdiff
Issue #16431: Also fix the opposite direction.
authorStefan Krah <skrah@bytereef.org>
Wed, 7 Nov 2012 22:47:19 +0000 (23:47 +0100)
committerStefan Krah <skrah@bytereef.org>
Wed, 7 Nov 2012 22:47:19 +0000 (23:47 +0100)
Lib/test/test_decimal.py
Modules/_decimal/_decimal.c

index 99faf784b1c4e74e23b3b4cb8af85e68e6bcfe58..ea18c6393e80531a0bd828c1ed6fdb7b5920b093 100644 (file)
@@ -2052,6 +2052,10 @@ class UsabilityTest(unittest.TestCase):
         self.assertIs(type(b), MyDecimal)
         self.assertEqual(a, b)
 
+        c = Decimal(b)
+        self.assertIs(type(c), Decimal)
+        self.assertEqual(a, c)
+
     def test_implicit_context(self):
         Decimal = self.decimal.Decimal
         getcontext = self.decimal.getcontext
index 0bc484f4ab13b58c2ed872cd5052de22f6c6f471..0e1d3044cad18ea3c556cb09734ea47029c0d18f 100644 (file)
@@ -2345,7 +2345,7 @@ PyDecType_FromDecimalExact(PyTypeObject *type, PyObject *v, PyObject *context)
     PyObject *dec;
     uint32_t status = 0;
 
-    if (type == &PyDec_Type) {
+    if (type == Py_TYPE(v)) {
         Py_INCREF(v);
         return v;
     }