diff options
Diffstat (limited to 'Modules/_decimal/_decimal.c')
| -rw-r--r-- | Modules/_decimal/_decimal.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c index f000887..22053b4 100644 --- a/Modules/_decimal/_decimal.c +++ b/Modules/_decimal/_decimal.c @@ -2630,12 +2630,18 @@ PyDecType_FromSequenceExact(PyTypeObject *type, PyObject *v, /* class method */ static PyObject * -dec_from_float(PyObject *dec, PyObject *pyfloat) +dec_from_float(PyObject *type, PyObject *pyfloat) { PyObject *context; + PyObject *result; CURRENT_CONTEXT(context); - return PyDecType_FromFloatExact((PyTypeObject *)dec, pyfloat, context); + result = PyDecType_FromFloatExact(&PyDec_Type, pyfloat, context); + if (type != (PyObject *)&PyDec_Type && result != NULL) { + Py_SETREF(result, PyObject_CallFunctionObjArgs(type, result, NULL)); + } + + return result; } /* create_decimal_from_float */ @@ -4529,7 +4535,7 @@ dec_sizeof(PyObject *v, PyObject *dummy UNUSED) { Py_ssize_t res; - res = sizeof(PyDecObject); + res = _PyObject_SIZE(Py_TYPE(v)); if (mpd_isdynamic_data(MPD(v))) { res += MPD(v)->alloc * sizeof(mpd_uint_t); } @@ -5640,7 +5646,7 @@ PyInit__decimal(void) goto error; /* GCOV_NOT_REACHED */ } - ASSIGN_PTR(cm->ex, PyErr_NewException((char *)cm->fqname, base, NULL)); + ASSIGN_PTR(cm->ex, PyErr_NewException(cm->fqname, base, NULL)); Py_DECREF(base); /* add to module */ @@ -5672,7 +5678,7 @@ PyInit__decimal(void) goto error; /* GCOV_NOT_REACHED */ } - ASSIGN_PTR(cm->ex, PyErr_NewException((char *)cm->fqname, base, NULL)); + ASSIGN_PTR(cm->ex, PyErr_NewException(cm->fqname, base, NULL)); Py_DECREF(base); Py_INCREF(cm->ex); |
