mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
- bool() called without arguments now returns False rather than
raising an exception. This is consistent with calling the constructors for the other builtin types -- called without argument they all return the false value of that type. (SF patch #724135) Thanks to Alex Martelli.
This commit is contained in:
parent
a26854095b
commit
aa86e35c52
4 changed files with 18 additions and 2 deletions
|
|
@ -51,10 +51,10 @@ static PyObject *
|
|||
bool_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
static char *kwlist[] = {"x", 0};
|
||||
PyObject *x;
|
||||
PyObject *x = Py_False;
|
||||
long ok;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:bool", kwlist, &x))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:bool", kwlist, &x))
|
||||
return NULL;
|
||||
ok = PyObject_IsTrue(x);
|
||||
if (ok < 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue