Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ed16eff

Browse files
author
Stefan Krah
committed
Issue #16431: Also fix the opposite direction.
1 parent f4abc7b commit ed16eff

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

Lib/test/test_decimal.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2052,6 +2052,10 @@ class MyDecimal(Decimal):
20522052
self.assertIs(type(b), MyDecimal)
20532053
self.assertEqual(a, b)
20542054

2055+
c = Decimal(b)
2056+
self.assertIs(type(c), Decimal)
2057+
self.assertEqual(a, c)
2058+
20552059
def test_implicit_context(self):
20562060
Decimal = self.decimal.Decimal
20572061
getcontext = self.decimal.getcontext

Modules/_decimal/_decimal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2345,7 +2345,7 @@ PyDecType_FromDecimalExact(PyTypeObject *type, PyObject *v, PyObject *context)
23452345
PyObject *dec;
23462346
uint32_t status = 0;
23472347

2348-
if (type == &PyDec_Type) {
2348+
if (type == Py_TYPE(v)) {
23492349
Py_INCREF(v);
23502350
return v;
23512351
}

0 commit comments

Comments
 (0)