summaryrefslogtreecommitdiffstats
path: root/Python/formatter_unicode.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2018-10-02 04:54:39 (GMT)
committerGitHub <noreply@github.com>2018-10-02 04:54:39 (GMT)
commitcbda8fc5d76b10bcbb92d927537576c229143836 (patch)
treea7e6b25e8c95fd72a78e11773dd6994b157013b9 /Python/formatter_unicode.c
parent30534cc7172f36092e0002bb7df482edc0d539ce (diff)
downloadcpython-cbda8fc5d76b10bcbb92d927537576c229143836.zip
cpython-cbda8fc5d76b10bcbb92d927537576c229143836.tar.gz
cpython-cbda8fc5d76b10bcbb92d927537576c229143836.tar.bz2
closes bpo-34868: Improve error message with '_' is combined with an invalid type specifier. (GH-9666)
Diffstat (limited to 'Python/formatter_unicode.c')
-rw-r--r--Python/formatter_unicode.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/Python/formatter_unicode.c b/Python/formatter_unicode.c
index 71e673d..ba09cc6 100644
--- a/Python/formatter_unicode.c
+++ b/Python/formatter_unicode.c
@@ -28,16 +28,17 @@ unknown_presentation_type(Py_UCS4 presentation_type,
}
static void
-invalid_comma_type(Py_UCS4 presentation_type)
+invalid_thousands_separator_type(char specifier, Py_UCS4 presentation_type)
{
+ assert(specifier == ',' || specifier == '_');
if (presentation_type > 32 && presentation_type < 128)
PyErr_Format(PyExc_ValueError,
- "Cannot specify ',' with '%c'.",
- (char)presentation_type);
+ "Cannot specify '%c' with '%c'.",
+ specifier, (char)presentation_type);
else
PyErr_Format(PyExc_ValueError,
- "Cannot specify ',' with '\\x%x'.",
- (unsigned int)presentation_type);
+ "Cannot specify '%c' with '\\x%x'.",
+ specifier, (unsigned int)presentation_type);
}
static void
@@ -117,8 +118,8 @@ is_sign_element(Py_UCS4 c)
/* Locale type codes. LT_NO_LOCALE must be zero. */
enum LocaleType {
LT_NO_LOCALE = 0,
- LT_DEFAULT_LOCALE,
- LT_UNDERSCORE_LOCALE,
+ LT_DEFAULT_LOCALE = ',',
+ LT_UNDERSCORE_LOCALE = '_',
LT_UNDER_FOUR_LOCALE,
LT_CURRENT_LOCALE
};
@@ -314,7 +315,7 @@ parse_internal_render_format_spec(PyObject *format_spec,
}
/* fall through */
default:
- invalid_comma_type(format->type);
+ invalid_thousands_separator_type(format->thousands_separators, format->type);
return 0;
}
}