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
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 @@
}
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 @@
(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},