mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Merged revisions 73868 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r73868 | amaury.forgeotdarc | 2009-07-07 02:43:08 +0200 (mar., 07 juil. 2009) | 3 lines #6428: py3k requires that __bool__ return a bool (and not an int) Fix the error message and the documentation. ........
This commit is contained in:
parent
c9722e56d5
commit
79fa5ab7b0
3 changed files with 11 additions and 9 deletions
|
@ -1254,11 +1254,11 @@ Basic customization
|
||||||
.. index:: single: __len__() (mapping object method)
|
.. index:: single: __len__() (mapping object method)
|
||||||
|
|
||||||
Called to implement truth value testing and the built-in operation
|
Called to implement truth value testing and the built-in operation
|
||||||
``bool()``; should return ``False`` or ``True``, or their integer equivalents
|
``bool()``; should return ``False`` or ``True``. When this method is not
|
||||||
``0`` or ``1``. When this method is not defined, :meth:`__len__` is called,
|
defined, :meth:`__len__` is called, if it is defined, and the object is
|
||||||
if it is defined, and the object is considered true if its result is nonzero.
|
considered true if its result is nonzero. If a class defines neither
|
||||||
If a class defines neither :meth:`__len__` nor :meth:`__bool__`, all its
|
:meth:`__len__` nor :meth:`__bool__`, all its instances are considered
|
||||||
instances are considered true.
|
true.
|
||||||
|
|
||||||
|
|
||||||
.. _attribute-access:
|
.. _attribute-access:
|
||||||
|
|
|
@ -12,6 +12,10 @@ What's New in Python 3.1.1?
|
||||||
Core and Builtins
|
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.
|
- 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
|
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.
|
defined in inttypes.h instead of stdint.h on that platform.
|
||||||
|
|
|
@ -4807,10 +4807,8 @@ slot_nb_bool(PyObject *self)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"%s should return "
|
"__bool__ should return "
|
||||||
"bool or int, returned %s",
|
"bool, returned %s",
|
||||||
(using_len ? "__len__"
|
|
||||||
: "__bool__"),
|
|
||||||
Py_TYPE(temp)->tp_name);
|
Py_TYPE(temp)->tp_name);
|
||||||
result = -1;
|
result = -1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue