summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_testcapimodule.c94
1 files changed, 93 insertions, 1 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index fbb4aa4..a21a584 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -1088,7 +1088,16 @@ getargs_c(PyObject *self, PyObject *args)
char c;
if (!PyArg_ParseTuple(args, "c", &c))
return NULL;
- return PyBytes_FromStringAndSize(&c, 1);
+ return PyLong_FromLong((unsigned char)c);
+}
+
+static PyObject *
+getargs_C(PyObject *self, PyObject *args)
+{
+ int c;
+ if (!PyArg_ParseTuple(args, "C", &c))
+ return NULL;
+ return PyLong_FromLong(c);
}
static PyObject *
@@ -1243,6 +1252,84 @@ getargs_Z_hash(PyObject *self, PyObject *args)
Py_RETURN_NONE;
}
+static PyObject *
+getargs_es(PyObject *self, PyObject *args)
+{
+ PyObject *arg, *result;
+ const char *encoding = NULL;
+ char *str;
+
+ if (!PyArg_ParseTuple(args, "O|s", &arg, &encoding))
+ return NULL;
+ if (!PyArg_Parse(arg, "es", encoding, &str))
+ return NULL;
+ result = PyBytes_FromString(str);
+ PyMem_Free(str);
+ return result;
+}
+
+static PyObject *
+getargs_et(PyObject *self, PyObject *args)
+{
+ PyObject *arg, *result;
+ const char *encoding = NULL;
+ char *str;
+
+ if (!PyArg_ParseTuple(args, "O|s", &arg, &encoding))
+ return NULL;
+ if (!PyArg_Parse(arg, "et", encoding, &str))
+ return NULL;
+ result = PyBytes_FromString(str);
+ PyMem_Free(str);
+ return result;
+}
+
+static PyObject *
+getargs_es_hash(PyObject *self, PyObject *args)
+{
+ PyObject *arg, *result;
+ const char *encoding = NULL;
+ PyByteArrayObject *buffer = NULL;
+ char *str = NULL;
+ Py_ssize_t size;
+
+ if (!PyArg_ParseTuple(args, "O|sY", &arg, &encoding, &buffer))
+ return NULL;
+ if (buffer != NULL) {
+ str = PyByteArray_AS_STRING(buffer);
+ size = PyByteArray_GET_SIZE(buffer);
+ }
+ if (!PyArg_Parse(arg, "es#", encoding, &str, &size))
+ return NULL;
+ result = PyBytes_FromStringAndSize(str, size);
+ if (buffer == NULL)
+ PyMem_Free(str);
+ return result;
+}
+
+static PyObject *
+getargs_et_hash(PyObject *self, PyObject *args)
+{
+ PyObject *arg, *result;
+ const char *encoding = NULL;
+ PyByteArrayObject *buffer = NULL;
+ char *str = NULL;
+ Py_ssize_t size;
+
+ if (!PyArg_ParseTuple(args, "O|sY", &arg, &encoding, &buffer))
+ return NULL;
+ if (buffer != NULL) {
+ str = PyByteArray_AS_STRING(buffer);
+ size = PyByteArray_GET_SIZE(buffer);
+ }
+ if (!PyArg_Parse(arg, "et#", encoding, &str, &size))
+ return NULL;
+ result = PyBytes_FromStringAndSize(str, size);
+ if (buffer == NULL)
+ PyMem_Free(str);
+ return result;
+}
+
/* Test the s and z codes for PyArg_ParseTuple.
*/
static PyObject *
@@ -3590,6 +3677,7 @@ static PyMethodDef TestMethods[] = {
{"test_L_code", (PyCFunction)test_L_code, METH_NOARGS},
#endif
{"getargs_c", getargs_c, METH_VARARGS},
+ {"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},
@@ -3604,6 +3692,10 @@ static PyMethodDef TestMethods[] = {
{"getargs_Z", getargs_Z, METH_VARARGS},
{"getargs_Z_hash", getargs_Z_hash, METH_VARARGS},
{"getargs_w_star", getargs_w_star, METH_VARARGS},
+ {"getargs_es", getargs_es, METH_VARARGS},
+ {"getargs_et", getargs_et, METH_VARARGS},
+ {"getargs_es_hash", getargs_es_hash, METH_VARARGS},
+ {"getargs_et_hash", getargs_et_hash, METH_VARARGS},
{"codec_incrementalencoder",
(PyCFunction)codec_incrementalencoder, METH_VARARGS},
{"codec_incrementaldecoder",