diff options
author | Eli Bendersky <eliben@gmail.com> | 2011-07-29 04:05:08 (GMT) |
---|---|---|
committer | Eli Bendersky <eliben@gmail.com> | 2011-07-29 04:05:08 (GMT) |
commit | 906b88fb2a52725e78deeb8076a52671107e2af1 (patch) | |
tree | b3a9397d8e65a13d275731f7447088389c0a3526 /Modules/_testcapimodule.c | |
parent | 66d2be898611f32e3840025055f2cd9b92b9f19c (diff) | |
download | cpython-906b88fb2a52725e78deeb8076a52671107e2af1.zip cpython-906b88fb2a52725e78deeb8076a52671107e2af1.tar.gz cpython-906b88fb2a52725e78deeb8076a52671107e2af1.tar.bz2 |
Issue #12380: PyArg_ParseTuple now accepts a bytearray for the 'c' format.
As a side effect, this now allows the rjust, ljust and center methods of
bytes and bytearray to accept a bytearray argument.
Patch by Petri Lehtinen
Diffstat (limited to 'Modules/_testcapimodule.c')
-rw-r--r-- | Modules/_testcapimodule.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 35d25e6..51c79c9 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -1003,6 +1003,15 @@ test_k_code(PyObject *self) } static PyObject * +getargs_c(PyObject *self, PyObject *args) +{ + char c; + if (!PyArg_ParseTuple(args, "c", &c)) + return NULL; + return PyBytes_FromStringAndSize(&c, 1); +} + +static PyObject * getargs_s(PyObject *self, PyObject *args) { char *str; @@ -2289,6 +2298,7 @@ static PyMethodDef TestMethods[] = { (PyCFunction)test_long_long_and_overflow, METH_NOARGS}, {"test_L_code", (PyCFunction)test_L_code, METH_NOARGS}, #endif + {"getargs_c", getargs_c, METH_VARARGS}, {"getargs_s", getargs_s, METH_VARARGS}, {"getargs_s_star", getargs_s_star, METH_VARARGS}, {"getargs_s_hash", getargs_s_hash, METH_VARARGS}, |