mirror of
https://github.com/python/cpython.git
synced 2025-11-02 03:01:58 +00:00
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:
parent
cd419abe42
commit
1205f2774e
8 changed files with 53 additions and 6 deletions
|
|
@ -2193,6 +2193,17 @@ crash_no_current_thread(PyObject *self)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
format_unicode(PyObject *self, PyObject *args)
|
||||
{
|
||||
const char *format;
|
||||
PyObject *arg;
|
||||
if (!PyArg_ParseTuple(args, "yU", &format, &arg))
|
||||
return NULL;
|
||||
return PyUnicode_FromFormat(format, arg);
|
||||
|
||||
}
|
||||
|
||||
static PyMethodDef TestMethods[] = {
|
||||
{"raise_exception", raise_exception, METH_VARARGS},
|
||||
{"raise_memoryerror", (PyCFunction)raise_memoryerror, METH_NOARGS},
|
||||
|
|
@ -2272,6 +2283,7 @@ static PyMethodDef TestMethods[] = {
|
|||
{"make_exception_with_doc", (PyCFunction)make_exception_with_doc,
|
||||
METH_VARARGS | METH_KEYWORDS},
|
||||
{"crash_no_current_thread", (PyCFunction)crash_no_current_thread, METH_NOARGS},
|
||||
{"format_unicode", format_unicode, METH_VARARGS},
|
||||
{NULL, NULL} /* sentinel */
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue