diff options
| author | Larry Hastings <larry@hastings.org> | 2012-05-05 16:54:29 -0700 |
|---|---|---|
| committer | Larry Hastings <larry@hastings.org> | 2012-05-05 16:54:29 -0700 |
| commit | 61215288bb0aece657bfa1c37d5ad0633c795c27 (patch) | |
| tree | a1623d4b2125607dae371fda0ca4e9b15e92b2fe /Python/getargs.c | |
| parent | 4f42824061228299c7273118d71503ef816ff376 (diff) | |
| download | cpython-61215288bb0aece657bfa1c37d5ad0633c795c27.tar.gz | |
Issue #14705: Add 'p' format character to PyArg_ParseTuple* for bool support.
Diffstat (limited to 'Python/getargs.c')
| -rw-r--r-- | Python/getargs.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Python/getargs.c b/Python/getargs.c index 8ec7110610..9e9695f4d2 100644 --- a/Python/getargs.c +++ b/Python/getargs.c @@ -814,6 +814,18 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags, break; } + case 'p': {/* boolean *p*redicate */ + int *p = va_arg(*p_va, int *); + int val = PyObject_IsTrue(arg); + if (val > 0) + *p = 1; + else if (val == 0) + *p = 0; + else + RETURN_ERR_OCCURRED; + break; + } + /* XXX WAAAAH! 's', 'y', 'z', 'u', 'Z', 'e', 'w' codes all need to be cleaned up! */ |
