Mercurial > cpython-lru_cache-weakref
diff Python/getargs.c @ 76776:bc6d28e726d8
Issue #14705: Add 'p' format character to PyArg_ParseTuple* for bool support.
| author | Larry Hastings <larry@hastings.org> |
|---|---|
| date | Sat, 05 May 2012 16:54:29 -0700 |
| parents | 052779d34945 |
| children | e4617650f006 |
line wrap: on
line diff
--- a/Python/getargs.c Sat May 05 22:37:05 2012 +0200 +++ b/Python/getargs.c Sat May 05 16:54:29 2012 -0700 @@ -814,6 +814,18 @@ 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! */
