Skip to content

Commit 5c4a5d2

Browse files
committed
Issue 6330: Fix --enable-unicode=ucs4.
1 parent 9ad0b36 commit 5c4a5d2

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

Objects/stringlib/formatter.h

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ unknown_presentation_type(STRINGLIB_CHAR presentation_type,
3232
PyErr_Format(PyExc_ValueError,
3333
"Unknown format code '%c' "
3434
"for object of type '%.200s'",
35-
presentation_type,
35+
(char)presentation_type,
3636
type_name);
3737
#if STRINGLIB_IS_UNICODE
3838
else
@@ -44,6 +44,24 @@ unknown_presentation_type(STRINGLIB_CHAR presentation_type,
4444
#endif
4545
}
4646

47+
static void
48+
invalid_comma_type(STRINGLIB_CHAR presentation_type)
49+
{
50+
#if STRINGLIB_IS_UNICODE
51+
/* See comment in unknown_presentation_type */
52+
if (presentation_type > 32 && presentation_type < 128)
53+
#endif
54+
PyErr_Format(PyExc_ValueError,
55+
"Cannot specify ',' with '%c'.",
56+
(char)presentation_type);
57+
#if STRINGLIB_IS_UNICODE
58+
else
59+
PyErr_Format(PyExc_ValueError,
60+
"Cannot specify ',' with '\\x%x'.",
61+
(unsigned int)presentation_type);
62+
#endif
63+
}
64+
4765
/*
4866
get_integer consumes 0 or more decimal digit characters from an
4967
input string, updates *result with the corresponding positive
@@ -253,8 +271,7 @@ parse_internal_render_format_spec(STRINGLIB_CHAR *format_spec,
253271
/* These are allowed. See PEP 378.*/
254272
break;
255273
default:
256-
PyErr_Format(PyExc_ValueError,
257-
"Cannot specify ',' with '%c'.", format->type);
274+
invalid_comma_type(format->type);
258275
return 0;
259276
}
260277
}

0 commit comments

Comments
 (0)