summaryrefslogtreecommitdiffstats
path: root/Python/formatter_unicode.c
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-05-13 21:24:49 (GMT)
committerGitHub <noreply@github.com>2021-05-13 21:24:49 (GMT)
commit2d780237d95cd3d95401f52be2edeac8b458eb68 (patch)
treeef3d237387c0b2bd0c2fe3ea10f03968e3db0b28 /Python/formatter_unicode.c
parentc4c3beb5ad6b55c20b6dc7c6a92860f467afa75b (diff)
downloadcpython-2d780237d95cd3d95401f52be2edeac8b458eb68.zip
cpython-2d780237d95cd3d95401f52be2edeac8b458eb68.tar.gz
cpython-2d780237d95cd3d95401f52be2edeac8b458eb68.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/formatter_unicode.c')
-rw-r--r--Python/formatter_unicode.c10
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;
}