From: Stefan Krah Date: Wed, 7 Nov 2012 22:47:19 +0000 (+0100) Subject: Issue #16431: Also fix the opposite direction. X-Git-Tag: v3.3.1rc1~670 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ed16eff57eaf5c89057f8da6328785fd887c01df;p=python Issue #16431: Also fix the opposite direction. --- diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py index 99faf784b1..ea18c6393e 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 0bc484f4ab..0e1d3044ca 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; }