diff options
author | Larry Hastings <larry@hastings.org> | 2012-05-05 23:54:29 (GMT) |
---|---|---|
committer | Larry Hastings <larry@hastings.org> | 2012-05-05 23:54:29 (GMT) |
commit | faf91e75ab287ae6c377b05b7eb91d7f5274fbc5 (patch) | |
tree | 5fd9ed01b383d818d84091f91efa22ce48b1bccb /Python/getargs.c | |
parent | 6b03f2ce45785190c6a8da271199ff724ba559d8 (diff) | |
download | cpython-faf91e75ab287ae6c377b05b7eb91d7f5274fbc5.zip cpython-faf91e75ab287ae6c377b05b7eb91d7f5274fbc5.tar.gz cpython-faf91e75ab287ae6c377b05b7eb91d7f5274fbc5.tar.bz2 |
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 8ec7110..9e9695f 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! */ |