summaryrefslogtreecommitdiffstats
path: root/Modules/_testcapimodule.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-09-11 00:54:47 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-09-11 00:54:47 (GMT)
commit1205f2774e00d38d3229a3a2742c2fcbc767bdde (patch)
tree8f5756aa974326bf503dfaad7512aff103bde9bb /Modules/_testcapimodule.c
parentcd419abe42b42c626d91d5f839d53bdbde9852e0 (diff)
downloadcpython-1205f2774e00d38d3229a3a2742c2fcbc767bdde.zip
cpython-1205f2774e00d38d3229a3a2742c2fcbc767bdde.tar.gz
cpython-1205f2774e00d38d3229a3a2742c2fcbc767bdde.tar.bz2
Issue #9738: PyUnicode_FromFormat() and PyErr_Format() raise an error on
a non-ASCII byte in the format string. Document also the encoding.
Diffstat (limited to 'Modules/_testcapimodule.c')
-rw-r--r--Modules/_testcapimodule.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index acbff34..20887b1 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -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 */
};