summaryrefslogtreecommitdiffstats
path: root/Objects/stringlib/formatter.h
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/stringlib/formatter.h')
-rw-r--r--Objects/stringlib/formatter.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/Objects/stringlib/formatter.h b/Objects/stringlib/formatter.h
index 3ca14fa..531bc22 100644
--- a/Objects/stringlib/formatter.h
+++ b/Objects/stringlib/formatter.h
@@ -785,8 +785,19 @@ FORMAT_STRING(PyObject* value, PyObject* args)
break;
default:
/* unknown */
- PyErr_Format(PyExc_ValueError, "Unknown conversion type %c",
- format.type);
+ #if STRINGLIB_IS_UNICODE
+ /* If STRINGLIB_CHAR is Py_UNICODE, %c might be out-of-range,
+ hence the two cases. If it is char, gcc complains that the
+ condition below is always true, hence the ifdef. */
+ if (format.type > 32 && format.type <128)
+ #endif
+ PyErr_Format(PyExc_ValueError, "Unknown conversion type %c",
+ (char)format.type);
+ #if STRINGLIB_IS_UNICODE
+ else
+ PyErr_Format(PyExc_ValueError, "Unknown conversion type '\\x%x'",
+ (unsigned int)format.type);
+ #endif
goto done;
}