mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue #14705: Add 'p' format character to PyArg_ParseTuple* for bool support.
This commit is contained in:
parent
6b03f2ce45
commit
faf91e75ab
4 changed files with 62 additions and 0 deletions
|
@ -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! */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue