diff Objects/stringlib/string_format.h @ 46335:3d9ad27d930b

Merged revisions 62199 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r62199 | martin.v.loewis | 2008-04-07 05:08:28 +0200 (Mo, 07 Apr 2008) | 2 lines 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:22:07 +0000
parents 09c9ceecdd56
children 23ab586c427a
line wrap: on
line diff
--- a/Objects/stringlib/string_format.h	Mon Apr 07 03:17:54 2008 +0000
+++ b/Objects/stringlib/string_format.h	Mon Apr 07 03:22:07 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;
     }
 }