diff options
author | Stefan Krah <skrah@bytereef.org> | 2012-11-07 22:47:19 (GMT) |
---|---|---|
committer | Stefan Krah <skrah@bytereef.org> | 2012-11-07 22:47:19 (GMT) |
commit | ed16eff57eaf5c89057f8da6328785fd887c01df (patch) | |
tree | 81a8ef54df0e9db30f5acf4ee1f6e338e850443c | |
parent | f4abc7b8a016da5b1783f471f2f376d7e9c27d60 (diff) | |
download | cpython-ed16eff57eaf5c89057f8da6328785fd887c01df.zip cpython-ed16eff57eaf5c89057f8da6328785fd887c01df.tar.gz cpython-ed16eff57eaf5c89057f8da6328785fd887c01df.tar.bz2 |
Issue #16431: Also fix the opposite direction.
-rw-r--r-- | Lib/test/test_decimal.py | 4 | ||||
-rw-r--r-- | 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 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; } |