mirror of
https://github.com/python/cpython
synced 2026-09-29 10:35:30 +03:00
Issue #8850: Remove "w" and "w#" formats from PyArg_Parse*() functions, use
"w*" format instead. Add tests for "w*" format.
This commit is contained in:
parent
21e09487ac
commit
25e8ec4724
6 changed files with 61 additions and 64 deletions
|
|
@ -1385,6 +1385,28 @@ test_widechar(PyObject *self)
|
|||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue