diff options
author | Eric Smith <eric@trueblade.com> | 2009-07-30 13:39:44 +0000 |
---|---|---|
committer | Eric Smith <eric@trueblade.com> | 2009-07-30 13:39:44 +0000 |
commit | 28c828e06a07fe0ec828ca234fc0a93301d29380 (patch) | |
tree | 859b735101f0e4f17453f7f033a2983ead822081 /Objects/stringlib | |
parent | 9e219189796ef53368f76bade7644ae4b329e1f3 (diff) | |
download | cpython-28c828e06a07fe0ec828ca234fc0a93301d29380.tar.gz |
Issue 6330: Fix --enable-unicode=ucs4.
Diffstat (limited to 'Objects/stringlib')
-rw-r--r-- | Objects/stringlib/formatter.h | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/Objects/stringlib/formatter.h b/Objects/stringlib/formatter.h index 5cead660c4..c722460472 100644 --- a/Objects/stringlib/formatter.h +++ b/Objects/stringlib/formatter.h @@ -32,7 +32,7 @@ unknown_presentation_type(STRINGLIB_CHAR presentation_type, PyErr_Format(PyExc_ValueError, "Unknown format code '%c' " "for object of type '%.200s'", - presentation_type, + (char)presentation_type, type_name); #if STRINGLIB_IS_UNICODE else @@ -44,6 +44,24 @@ unknown_presentation_type(STRINGLIB_CHAR presentation_type, #endif } +static void +invalid_comma_type(STRINGLIB_CHAR presentation_type) +{ +#if STRINGLIB_IS_UNICODE + /* See comment in unknown_presentation_type */ + if (presentation_type > 32 && presentation_type < 128) +#endif + PyErr_Format(PyExc_ValueError, + "Cannot specify ',' with '%c'.", + (char)presentation_type); +#if STRINGLIB_IS_UNICODE + else + PyErr_Format(PyExc_ValueError, + "Cannot specify ',' with '\\x%x'.", + (unsigned int)presentation_type); +#endif +} + /* get_integer consumes 0 or more decimal digit characters from an input string, updates *result with the corresponding positive @@ -253,8 +271,7 @@ parse_internal_render_format_spec(STRINGLIB_CHAR *format_spec, /* These are allowed. See PEP 378.*/ break; default: - PyErr_Format(PyExc_ValueError, - "Cannot specify ',' with '%c'.", format->type); + invalid_comma_type(format->type); return 0; } } |