[Python-checkins] r73869 - in python/branches/release31-maint: Doc/reference/datamodel.rst Misc/NEWS Objects/typeobject.c

amaury.forgeotdarc python-checkins at python.org
Tue Jul 7 02:45:43 CEST 2009


Author: amaury.forgeotdarc
Date: Tue Jul  7 02:45:43 2009
New Revision: 73869

Log:
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.
........


Modified:
   python/branches/release31-maint/   (props changed)
   python/branches/release31-maint/Doc/reference/datamodel.rst
   python/branches/release31-maint/Misc/NEWS
   python/branches/release31-maint/Objects/typeobject.c

Modified: python/branches/release31-maint/Doc/reference/datamodel.rst
==============================================================================
--- python/branches/release31-maint/Doc/reference/datamodel.rst	(original)
+++ python/branches/release31-maint/Doc/reference/datamodel.rst	Tue Jul  7 02:45:43 2009
@@ -1254,11 +1254,11 @@
    .. 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:

Modified: python/branches/release31-maint/Misc/NEWS
==============================================================================
--- python/branches/release31-maint/Misc/NEWS	(original)
+++ python/branches/release31-maint/Misc/NEWS	Tue Jul  7 02:45:43 2009
@@ -12,6 +12,10 @@
 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.

Modified: python/branches/release31-maint/Objects/typeobject.c
==============================================================================
--- python/branches/release31-maint/Objects/typeobject.c	(original)
+++ python/branches/release31-maint/Objects/typeobject.c	Tue Jul  7 02:45:43 2009
@@ -4807,10 +4807,8 @@
 			}
 			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;
 			}


More information about the Python-checkins mailing list