diff options
Diffstat (limited to 'Modules/_decimal')
-rw-r--r-- | Modules/_decimal/_decimal.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c index 5e9fd67..89386ff 100644 --- a/Modules/_decimal/_decimal.c +++ b/Modules/_decimal/_decimal.c @@ -3222,7 +3222,13 @@ dec_format(PyObject *dec, PyObject *args) decstring = mpd_qformat_spec(MPD(dec), &spec, CTX(context), &status); if (decstring == NULL) { - dec_addstatus(context, status); + if (status & MPD_Malloc_error) { + PyErr_NoMemory(); + } + else { + PyErr_SetString(PyExc_ValueError, + "format specification exceeds internal limits of _decimal"); + } goto finish; } result = PyUnicode_DecodeUTF8(decstring, strlen(decstring), NULL); |