[Python-checkins] cpython (3.3): Issue #16431: Also fix the opposite direction.

stefan.krah python-checkins at python.org
Wed Nov 7 23:55:16 CET 2012


http://hg.python.org/cpython/rev/7fcc58811e82
changeset:   80295:7fcc58811e82
branch:      3.3
parent:      80293:1b6c972457e6
user:        Stefan Krah <skrah at bytereef.org>
date:        Wed Nov 07 23:47:19 2012 +0100
summary:
  Issue #16431: Also fix the opposite direction.

files:
  Lib/test/test_decimal.py    |  4 ++++
  Modules/_decimal/_decimal.c |  2 +-
  2 files changed, 5 insertions(+), 1 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
@@ -2052,6 +2052,10 @@
         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
diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c
--- a/Modules/_decimal/_decimal.c
+++ b/Modules/_decimal/_decimal.c
@@ -2345,7 +2345,7 @@
     PyObject *dec;
     uint32_t status = 0;
 
-    if (type == &PyDec_Type) {
+    if (type == Py_TYPE(v)) {
         Py_INCREF(v);
         return v;
     }

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


More information about the Python-checkins mailing list