diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2021-05-13 21:35:30 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-13 21:35:30 (GMT) |
commit | 133013e8a1ecd570266de766e2df9745a24343be (patch) | |
tree | d79ae29351167ec16f8acd2051b07cdaef877947 /Python | |
parent | 04c46101944777dd131bbfe8dbfef5f4d328860d (diff) | |
download | cpython-133013e8a1ecd570266de766e2df9745a24343be.zip cpython-133013e8a1ecd570266de766e2df9745a24343be.tar.gz cpython-133013e8a1ecd570266de766e2df9745a24343be.tar.bz2 |
bpo-28146: Fix a confusing error message in str.format() (GH-24213)
Automerge-Triggered-By: GH:pitrou
(cherry picked from commit 4aeee0b47b3a2b604bbac37040320ffc88c291f2)
Co-authored-by: Irit Katriel <iritkatriel@yahoo.com>
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 ed95f26..e7ec4dd 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; } |