summaryrefslogtreecommitdiffstats
path: root/Modules/_testcapimodule.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-06-25 00:02:38 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-06-25 00:02:38 (GMT)
commit25e8ec47244b405083b5fe7b353560666cabff44 (patch)
tree2412de21beab51e376834501ddf8beb866b40df9 /Modules/_testcapimodule.c
parent21e09487ac9d4365819ae4de31319ae3df9a8b17 (diff)
downloadcpython-25e8ec47244b405083b5fe7b353560666cabff44.zip
cpython-25e8ec47244b405083b5fe7b353560666cabff44.tar.gz
cpython-25e8ec47244b405083b5fe7b353560666cabff44.tar.bz2
Issue #8850: Remove "w" and "w#" formats from PyArg_Parse*() functions, use
"w*" format instead. Add tests for "w*" format.
Diffstat (limited to 'Modules/_testcapimodule.c')
-rw-r--r--Modules/_testcapimodule.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index 7bcc1d8..acbff34 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -1386,6 +1386,28 @@ test_widechar(PyObject *self)
}
static PyObject *
+getargs_w_star(PyObject *self, PyObject *args)
+{
+ Py_buffer buffer;
+ PyObject *result;
+ char *str;
+
+ if (!PyArg_ParseTuple(args, "w*:getargs_w_star", &buffer))
+ return NULL;
+
+ if (2 <= buffer.len) {
+ str = buffer.buf;
+ str[0] = '[';
+ str[buffer.len-1] = ']';
+ }
+
+ result = PyBytes_FromStringAndSize(buffer.buf, buffer.len);
+ PyBuffer_Release(&buffer);
+ return result;
+}
+
+
+static PyObject *
test_empty_argparse(PyObject *self)
{
/* Test that formats can begin with '|'. See issue #4720. */
@@ -2227,6 +2249,7 @@ static PyMethodDef TestMethods[] = {
{"getargs_u_hash", getargs_u_hash, METH_VARARGS},
{"getargs_Z", getargs_Z, METH_VARARGS},
{"getargs_Z_hash", getargs_Z_hash, METH_VARARGS},
+ {"getargs_w_star", getargs_w_star, METH_VARARGS},
{"codec_incrementalencoder",
(PyCFunction)codec_incrementalencoder, METH_VARARGS},
{"codec_incrementaldecoder",