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.
........
This commit is contained in:
Martin v. Löwis 2008-04-07 03:22:07 +00:00
parent d218dc15e6
commit 5a6f4585fd
3 changed files with 25 additions and 6 deletions

View File

@ -785,8 +785,19 @@ FORMAT_STRING(PyObject* value, PyObject* args)
break; break;
default: default:
/* unknown */ /* unknown */
PyErr_Format(PyExc_ValueError, "Unknown conversion type %c", #if STRINGLIB_IS_UNICODE
format.type); /* 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; goto done;
} }

View File

@ -740,9 +740,17 @@ do_conversion(PyObject *obj, STRINGLIB_CHAR conversion)
case 's': case 's':
return STRINGLIB_TOSTR(obj); return STRINGLIB_TOSTR(obj);
default: default:
PyErr_Format(PyExc_ValueError, if (conversion > 32 && conversion < 127) {
"Unknown converion specifier %c", /* It's the ASCII subrange; casting to char is safe
conversion); (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; return NULL;
} }
} }

View File

@ -8895,7 +8895,7 @@ PyObject *PyUnicode_Format(PyObject *format,
if (!isnumok) { if (!isnumok) {
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
"%%%c format: a number is required, " "%%%c format: a number is required, "
"not %.200s", c, Py_TYPE(v)->tp_name); "not %.200s", (char)c, Py_TYPE(v)->tp_name);
goto onError; goto onError;
} }
if (flags & F_ZERO) if (flags & F_ZERO)