Issue #9738: PyUnicode_FromFormat() and PyErr_Format() raise an error on

a non-ASCII byte in the format string.

Document also the encoding.
This commit is contained in:
Victor Stinner 2010-09-11 00:54:47 +00:00
parent cd419abe42
commit 1205f2774e
8 changed files with 53 additions and 6 deletions

View file

@ -1102,7 +1102,15 @@ PyUnicode_FromFormatV(const char *format, va_list vargs)
appendstring(p);
goto end;
}
} else
}
else if (128 <= (unsigned char)*f) {
PyErr_Format(PyExc_ValueError,
"PyUnicode_FromFormatV() expects an ASCII-encoded format "
"string, got a non-ascii byte: 0x%02x",
(unsigned char)*f);
goto fail;
}
else
*s++ = *f;
}