This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Improve bool TypeError message
Type: enhancement Stage:
Components: Interpreter Core Versions: Python 3.2
process
Status: closed Resolution: duplicate
Dependencies: Superseder: TypeError: __bool__ should return bool or int, returned int
View: 6428
Assigned To: Nosy List: r.david.murray, terry.reedy
Priority: normal Keywords: easy

Created on 2009-07-09 21:21 by terry.reedy, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (7)
msg90355 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2009-07-09 21:21
>>> 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.
msg90356 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-07-09 21:40
The error message is in error.  Int is not allowed in 3.x, only bool. 
This is thus superseded by issue 6428, which has already been fixed.
msg90374 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2009-07-10 03:37
Phooey. I searched for 'bool TypeError' but it failed to return 6428.
I will ask on py-dev why not.
msg90398 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2009-07-10 21:33
Testing.
I am 99.9% sure *I* did not reopen. Testing to see if OP post auto-reopens.
msg90399 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2009-07-10 21:36
Must have been random glitch. I certainly did not change state and priority.
msg90401 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-07-11 02:27
On your test post I got deleted from the nosy list.  Was that intentional?

I wonder if your browser is doing something weird with the form field
settings.  Or it may have as you say been a random thing...I know that
has happened to me once or twice where I refreshed the page in an odd
order and reset some fields I wasn't intending to reset.
msg90403 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2009-07-11 04:58
yes, I was trying to avoid bothering you with the noise.
This is one of those 'everything gone wrong' situations.
If only I had unselected 'open only' when I did the search...
History
Date User Action Args
2022-04-11 14:56:50adminsetgithub: 50702
2010-04-27 20:33:24loewissetpriority: normal
2009-07-11 04:58:44terry.reedysetmessages: + msg90403
2009-07-11 02:27:52r.david.murraysetnosy: + r.david.murray
messages: + msg90401
2009-07-10 21:36:02terry.reedysetmessages: + msg90399
2009-07-10 21:33:12terry.reedysetnosy: - r.david.murray
messages: + msg90398
2009-07-10 08:53:36amaury.forgeotdarcsetstatus: open -> closed
resolution: duplicate
2009-07-10 03:37:25terry.reedysetstatus: closed -> open
priority: normal -> (no value)
messages: + msg90374

resolution: duplicate -> (no value)
stage: resolved ->
2009-07-09 21:40:27r.david.murraysetstatus: open -> closed
priority: normal
superseder: TypeError: __bool__ should return bool or int, returned int


nosy: + r.david.murray
messages: + msg90356
resolution: duplicate
stage: resolved
2009-07-09 21:21:28terry.reedycreate