[issue6453] Improve bool TypeError message

Terry J. Reedy report at bugs.python.org
Thu Jul 9 23:21:29 CEST 2009


New submission from Terry J. Reedy <tjreedy at udel.edu>:

>>> cc=c()
>>> bool(cc)
Traceback (most recent call last):
  File "<pyshell#5>", line 1, in <module>
    bool(cc)
TypeError: __bool__ should return bool or int, returned int

This is slightly jarring.
Adding ' 0 or 1' after 'or int' would be nice (and trivial).
Adding str(val) at the end after type(val) would be even nicer.

----------
components: Interpreter Core
keywords: easy
messages: 90355
nosy: tjreedy
severity: normal
status: open
title: Improve bool TypeError message
type: feature request
versions: Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6453>
_______________________________________


More information about the Python-bugs-list mailing list