Terry J. Reedy added the comment:

https://docs.python.org/3/library/functions.html#bool refers to
https://docs.python.org/3/library/stdtypes.html#truth

The latter says that values are true ("All other values are considered true") 
unless one of certain conditions holds.  For user-defined classes, the 
condition is that the class defines a __bool__() or __len__() method and that 
the first of those methods returns the bool False or integer zero.

I easily interpret this as meaning that bool(x) (should) *always* return True 
or False.  In particular, for user classes, any exception in user-coded 
__bool__ or __len__ (should be) included in "does not return integer zero or 
bool value False".  This would mean that 'True' would truly be the default 
return for Bool().

There is currently an unstated exception for raised Exceptions.  This issue 
proposes an exception to the exception for OverflowErrors (once negative 
lengths consistently raise ValueErrors and never OverflowErrors).  While this 
sensible in itself, I am completely happy with the added complication.  I would 
like to either reconsider the exception for Exceptions or make it explicit.

Patch has new text and What's New entry.  Added logic in object.c looks correct.

----------
nosy: +terry.reedy

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29840>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to