mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
Since the return type of format() is not a Decimal, raise ValueError instead of
InvalidOperation if the format specification (width, prec) exceeds the internal limits of libmpdec.
This commit is contained in:
parent
33f7cdd975
commit
eb8c451bd2
2 changed files with 11 additions and 11 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue