summaryrefslogtreecommitdiffstats
path: root/Modules/_testcapimodule.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2008-12-22 20:51:15 (GMT)
committerBenjamin Peterson <benjamin@python.org>2008-12-22 20:51:15 (GMT)
commit4caef5c7e2f3b0de2725d83e8eab20f5dd3d6195 (patch)
tree68a77c855b6458c9a756b7c1fbc89c66dc4867e4 /Modules/_testcapimodule.c
parent1c3978525678ea52e601e4d8571676385f767e0f (diff)
downloadcpython-4caef5c7e2f3b0de2725d83e8eab20f5dd3d6195.zip
cpython-4caef5c7e2f3b0de2725d83e8eab20f5dd3d6195.tar.gz
cpython-4caef5c7e2f3b0de2725d83e8eab20f5dd3d6195.tar.bz2
fix #4720: the format to PyArg_ParseTupleAndKeywords can now start with '|'
Diffstat (limited to 'Modules/_testcapimodule.c')
-rw-r--r--Modules/_testcapimodule.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index adb04c0..d7ec730 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -519,6 +519,32 @@ test_u_code(PyObject *self)
}
static PyObject *
+test_empty_argparse(PyObject *self)
+{
+ /* Test that formats can begin with '|'. See issue #4720. */
+ PyObject *tuple, *dict = NULL;
+ static char *kwlist[] = {NULL};
+ int result;
+ tuple = PyTuple_New(0);
+ if (!tuple)
+ return NULL;
+ if ((result = PyArg_ParseTuple(tuple, "|:test_empty_argparse")) < 0)
+ goto done;
+ dict = PyDict_New();
+ if (!dict)
+ goto done;
+ result = PyArg_ParseTupleAndKeywords(tuple, dict, "|:test_empty_argparse", kwlist);
+ done:
+ Py_DECREF(tuple);
+ Py_XDECREF(dict);
+ if (result < 0)
+ return NULL;
+ else {
+ Py_RETURN_NONE;
+ }
+}
+
+static PyObject *
codec_incrementalencoder(PyObject *self, PyObject *args)
{
const char *encoding, *errors = NULL;
@@ -780,6 +806,7 @@ static PyMethodDef TestMethods[] = {
{"test_long_api", (PyCFunction)test_long_api, METH_NOARGS},
{"test_long_numbits", (PyCFunction)test_long_numbits, METH_NOARGS},
{"test_k_code", (PyCFunction)test_k_code, METH_NOARGS},
+ {"test_empty_argparse", (PyCFunction)test_empty_argparse,METH_NOARGS},
{"test_null_strings", (PyCFunction)test_null_strings, METH_NOARGS},
{"test_string_from_format", (PyCFunction)test_string_from_format, METH_NOARGS},
{"test_with_docstring", (PyCFunction)test_with_docstring, METH_NOARGS,