mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-15999: Accept arbitrary values for boolean parameters. (#15609)
builtins and extension module functions and methods that expect boolean values for parameters now accept any Python object rather than just a bool or int type. This is more consistent with how native Python code itself behaves.
This commit is contained in:
parent
c68573b339
commit
a87c46eab3
52 changed files with 297 additions and 302 deletions
|
@ -2928,8 +2928,8 @@ sock_setblocking(PySocketSockObject *s, PyObject *arg)
|
|||
{
|
||||
long block;
|
||||
|
||||
block = PyLong_AsLong(arg);
|
||||
if (block == -1 && PyErr_Occurred())
|
||||
block = PyObject_IsTrue(arg);
|
||||
if (block < 0)
|
||||
return NULL;
|
||||
|
||||
s->sock_timeout = _PyTime_FromSeconds(block ? -1 : 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue