diff Objects/stringlib/formatter.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 30c4e1ca8421
children ef4ec968fdb6
line wrap: on
line diff
--- a/Objects/stringlib/formatter.h	Mon Apr 07 03:17:54 2008 +0000
+++ b/Objects/stringlib/formatter.h	Mon Apr 07 03:22:07 2008 +0000
@@ -785,8 +785,19 @@
         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;
     }