diff options
-rw-r--r-- | Doc/reference/datamodel.rst | 10 | ||||
-rw-r--r-- | Misc/NEWS | 4 | ||||
-rw-r--r-- | Objects/typeobject.c | 6 |
3 files changed, 11 insertions, 9 deletions
diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index 2161706..d0aa59f 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -1254,11 +1254,11 @@ Basic customization .. index:: single: __len__() (mapping object method) Called to implement truth value testing and the built-in operation - ``bool()``; should return ``False`` or ``True``, or their integer equivalents - ``0`` or ``1``. When this method is not defined, :meth:`__len__` is called, - if it is defined, and the object is considered true if its result is nonzero. - If a class defines neither :meth:`__len__` nor :meth:`__bool__`, all its - instances are considered true. + ``bool()``; should return ``False`` or ``True``. When this method is not + defined, :meth:`__len__` is called, if it is defined, and the object is + considered true if its result is nonzero. If a class defines neither + :meth:`__len__` nor :meth:`__bool__`, all its instances are considered + true. .. _attribute-access: @@ -12,6 +12,10 @@ What's New in Python 3.1.1? Core and Builtins ----------------- +- Issue #6428: Since Python 3.0, the __bool__ method must return a bool + object, and not an int. Fix the corresponding error message, and the + documentation. + - Issue #6347: Include inttypes.h as well as stdint.h in pyport.h. This fixes a build failure on HP-UX: int32_t and uint32_t are defined in inttypes.h instead of stdint.h on that platform. diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 0e79542..60483e7 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -4807,10 +4807,8 @@ slot_nb_bool(PyObject *self) } else { PyErr_Format(PyExc_TypeError, - "%s should return " - "bool or int, returned %s", - (using_len ? "__len__" - : "__bool__"), + "__bool__ should return " + "bool, returned %s", Py_TYPE(temp)->tp_name); result = -1; } |