summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Krah <skrah@bytereef.org>2012-11-07 22:47:19 (GMT)
committerStefan Krah <skrah@bytereef.org>2012-11-07 22:47:19 (GMT)
commited16eff57eaf5c89057f8da6328785fd887c01df (patch)
tree81a8ef54df0e9db30f5acf4ee1f6e338e850443c
parentf4abc7b8a016da5b1783f471f2f376d7e9c27d60 (diff)
downloadcpython-ed16eff57eaf5c89057f8da6328785fd887c01df.zip
cpython-ed16eff57eaf5c89057f8da6328785fd887c01df.tar.gz
cpython-ed16eff57eaf5c89057f8da6328785fd887c01df.tar.bz2
Issue #16431: Also fix the opposite direction.
-rw-r--r--Lib/test/test_decimal.py4
-rw-r--r--Modules/_decimal/_decimal.c2
2 files changed, 5 insertions, 1 deletions
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py
index 99faf78..ea18c63 100644
--- a/Lib/test/test_decimal.py
+++ b/Lib/test/test_decimal.py
@@ -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
diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c
index 0bc484f..0e1d304 100644
--- a/Modules/_decimal/_decimal.c
+++ b/Modules/_decimal/_decimal.c
@@ -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;
}