File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -556,6 +556,13 @@ ms_err_truncated(void)
556556 return -1;
557557}
558558
559+ static int
560+ ms_decimal_format_error(void)
561+ {
562+ PyErr_SetString(PyExc_TypeError, "callable returned a value containing a Decimal");
563+ return -1;
564+ }
565+
559566/*************************************************************************
560567 * Utilities *
561568 *************************************************************************/
@@ -13478,11 +13485,7 @@ mpack_encode_decimal(EncoderState *self, PyObject *obj)
1347813485 }
1347913486 else {
1348013487 if (self->in_decimal_callable) {
13481- PyErr_SetString(
13482- PyExc_TypeError,
13483- "callable returned a value containing a Decimal"
13484- );
13485- return -1;
13488+ return ms_decimal_format_error();
1348613489 }
1348713490 temp = PyObject_CallFunctionObjArgs(self->decimal_callable, obj, NULL);
1348813491 if (temp == NULL) return -1;
@@ -14133,11 +14136,7 @@ json_encode_decimal(EncoderState *self, PyObject *obj)
1413314136
1413414137 if (self->decimal_format == DECIMAL_FORMAT_CALLABLE) {
1413514138 if (self->in_decimal_callable) {
14136- PyErr_SetString(
14137- PyExc_TypeError,
14138- "callable returned a value containing a Decimal"
14139- );
14140- return -1;
14139+ return ms_decimal_format_error();
1414114140 }
1414214141 temp = PyObject_CallFunctionObjArgs(self->decimal_callable, obj, NULL);
1414314142 if (temp == NULL) return -1;
You can’t perform that action at this time.
0 commit comments