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>
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;
     }