Issue #8850: Remove "w" and "w#" formats from PyArg_Parse*() functions, use
"w*" format instead. Add tests for "w*" format.
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 @@
}
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 @@
{"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",