Issue #14705: Add 'p' format character to PyArg_ParseTuple* for bool support.

This commit is contained in:
Larry Hastings 2012-05-05 16:54:29 -07:00
parent 6b03f2ce45
commit faf91e75ab
4 changed files with 62 additions and 0 deletions

View file

@ -916,6 +916,15 @@ getargs_n(PyObject *self, PyObject *args)
return PyLong_FromSsize_t(value);
}
static PyObject *
getargs_p(PyObject *self, PyObject *args)
{
int value;
if (!PyArg_ParseTuple(args, "p", &value))
return NULL;
return PyLong_FromLong(value);
}
#ifdef HAVE_LONG_LONG
static PyObject *
getargs_L(PyObject *self, PyObject *args)
@ -2439,6 +2448,7 @@ static PyMethodDef TestMethods[] = {
{"getargs_i", getargs_i, METH_VARARGS},
{"getargs_l", getargs_l, METH_VARARGS},
{"getargs_n", getargs_n, METH_VARARGS},
{"getargs_p", getargs_p, METH_VARARGS},
#ifdef HAVE_LONG_LONG
{"getargs_L", getargs_L, METH_VARARGS},
{"getargs_K", getargs_K, METH_VARARGS},