summaryrefslogtreecommitdiffstats
path: root/Modules/_testcapimodule.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-05-16 07:11:47 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-05-16 07:11:47 (GMT)
commitf95455da4c3c61a302d62322a4bcb17a629efd4b (patch)
treeedce042440c577bea729621e113d7cc97fcad1ba /Modules/_testcapimodule.c
parentacef5de6ecd1cb84420bb0ea8d0a8d6cd09682e2 (diff)
downloadcpython-f95455da4c3c61a302d62322a4bcb17a629efd4b.zip
cpython-f95455da4c3c61a302d62322a4bcb17a629efd4b.tar.gz
cpython-f95455da4c3c61a302d62322a4bcb17a629efd4b.tar.bz2
Issue #26995: Added tests for "f", "d", "D", "S", "Y", and "U" format codes
in PyArg_ParseTuple().
Diffstat (limited to 'Modules/_testcapimodule.c')
-rw-r--r--Modules/_testcapimodule.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index 19fea20..d86af15 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -1103,6 +1103,63 @@ test_k_code(PyObject *self)
}
static PyObject *
+getargs_f(PyObject *self, PyObject *args)
+{
+ float f;
+ if (!PyArg_ParseTuple(args, "f", &f))
+ return NULL;
+ return PyFloat_FromDouble(f);
+}
+
+static PyObject *
+getargs_d(PyObject *self, PyObject *args)
+{
+ double d;
+ if (!PyArg_ParseTuple(args, "d", &d))
+ return NULL;
+ return PyFloat_FromDouble(d);
+}
+
+static PyObject *
+getargs_D(PyObject *self, PyObject *args)
+{
+ Py_complex cval;
+ if (!PyArg_ParseTuple(args, "D", &cval))
+ return NULL;
+ return PyComplex_FromCComplex(cval);
+}
+
+static PyObject *
+getargs_S(PyObject *self, PyObject *args)
+{
+ PyObject *obj;
+ if (!PyArg_ParseTuple(args, "S", &obj))
+ return NULL;
+ Py_INCREF(obj);
+ return obj;
+}
+
+static PyObject *
+getargs_Y(PyObject *self, PyObject *args)
+{
+ PyObject *obj;
+ if (!PyArg_ParseTuple(args, "Y", &obj))
+ return NULL;
+ Py_INCREF(obj);
+ return obj;
+}
+
+static PyObject *
+getargs_U(PyObject *self, PyObject *args)
+{
+ PyObject *obj;
+ if (!PyArg_ParseTuple(args, "U", &obj))
+ return NULL;
+ Py_INCREF(obj);
+ return obj;
+}
+
+static PyObject *
getargs_c(PyObject *self, PyObject *args)
{
char c;
@@ -3696,6 +3753,12 @@ static PyMethodDef TestMethods[] = {
(PyCFunction)test_long_long_and_overflow, METH_NOARGS},
{"test_L_code", (PyCFunction)test_L_code, METH_NOARGS},
#endif
+ {"getargs_f", getargs_f, METH_VARARGS},
+ {"getargs_d", getargs_d, METH_VARARGS},
+ {"getargs_D", getargs_D, METH_VARARGS},
+ {"getargs_S", getargs_S, METH_VARARGS},
+ {"getargs_Y", getargs_Y, METH_VARARGS},
+ {"getargs_U", getargs_U, METH_VARARGS},
{"getargs_c", getargs_c, METH_VARARGS},
{"getargs_C", getargs_C, METH_VARARGS},
{"getargs_s", getargs_s, METH_VARARGS},