mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-28146: Fix a confusing error message in str.format() (GH-24213)
Automerge-Triggered-By: GH:pitrou
(cherry picked from commit 4aeee0b47b
)
Co-authored-by: Irit Katriel <iritkatriel@yahoo.com>
This commit is contained in:
parent
c4c3beb5ad
commit
2d780237d9
3 changed files with 14 additions and 4 deletions
|
@ -773,8 +773,14 @@ format_string_internal(PyObject *value, const InternalFormatSpec *format,
|
|||
|
||||
/* sign is not allowed on strings */
|
||||
if (format->sign != '\0') {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"Sign not allowed in string format specifier");
|
||||
if (format->sign == ' ') {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"Space not allowed in string format specifier");
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"Sign not allowed in string format specifier");
|
||||
}
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue