diff options
| author | Irit Katriel <iritkatriel@yahoo.com> | 2021-05-13 20:55:55 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-13 20:55:55 (GMT) |
| commit | 4aeee0b47b3a2b604bbac37040320ffc88c291f2 (patch) | |
| tree | 1e33802dd3bcc1c4d7590aabb985bc787eca1d81 /Python | |
| parent | ae3c66acb89a6104fcd0eea760f80a0287327cc4 (diff) | |
| download | cpython-4aeee0b47b3a2b604bbac37040320ffc88c291f2.zip cpython-4aeee0b47b3a2b604bbac37040320ffc88c291f2.tar.gz cpython-4aeee0b47b3a2b604bbac37040320ffc88c291f2.tar.bz2 | |
bpo-28146: Fix a confusing error message in str.format() (GH-24213)
Automerge-Triggered-By: GH:pitrou
Diffstat (limited to 'Python')
| -rw-r--r-- | Python/formatter_unicode.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Python/formatter_unicode.c b/Python/formatter_unicode.c index 5ccf9d3..7b5a7bd 100644 --- a/Python/formatter_unicode.c +++ b/Python/formatter_unicode.c @@ -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; } |
