diff Objects/stringlib/string_format.h @ 46333:4e72489f16d0 legacy-trunk

Bug #2388: Fix gcc warnings when compiling with --enable-unicode=ucs4.
author Martin v. Löwis <martin@v.loewis.de>
date Mon, 07 Apr 2008 03:08:28 +0000
parents a77e1cf7ed25
children 4fe192d48960
line wrap: on
line diff
--- a/Objects/stringlib/string_format.h	Mon Apr 07 01:59:40 2008 +0000
+++ b/Objects/stringlib/string_format.h	Mon Apr 07 03:08:28 2008 +0000
@@ -740,9 +740,17 @@
     case 's':
         return STRINGLIB_TOSTR(obj);
     default:
-        PyErr_Format(PyExc_ValueError,
-                     "Unknown converion specifier %c",
-                     conversion);
+	if (conversion > 32 && conversion < 127) {
+		/* It's the ASCII subrange; casting to char is safe
+		   (assuming the execution character set is an ASCII
+		   superset). */
+        	PyErr_Format(PyExc_ValueError,
+                     "Unknown conversion specifier %c",
+                     (char)conversion);
+	} else
+		PyErr_Format(PyExc_ValueError,
+		     "Unknown conversion specifier \\x%x",
+		     (unsigned int)conversion);
         return NULL;
     }
 }