From a54ab6a21c2d2a11098e73a4e9a72020496ecca4 Mon Sep 17 00:00:00 2001 From: "Eric V. Smith" Date: Tue, 15 Apr 2014 22:37:55 -0400 Subject: Close issue #8931: Make alternate formatting for 'c' raise an exception. Patch by Torsten Landschoff. --- Python/formatter_unicode.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'Python/formatter_unicode.c') diff --git a/Python/formatter_unicode.c b/Python/formatter_unicode.c index e3a8149841..056bb76902 100644 --- a/Python/formatter_unicode.c +++ b/Python/formatter_unicode.c @@ -846,6 +846,13 @@ format_long_internal(PyObject *value, const InternalFormatSpec *format, " format specifier 'c'"); goto done; } + /* error to request alternate format */ + if (format->alternate) { + PyErr_SetString(PyExc_ValueError, + "Alternate form (#) not allowed with integer" + " format specifier 'c'"); + goto done; + } /* taken from unicodeobject.c formatchar() */ /* Integer input truncated to a character */ -- cgit v1.2.1