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: Builtin __bool__ docstrings are wrong
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.11
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: JelleZijlstra Nosy List: JelleZijlstra, miss-islington, terry.reedy
Priority: normal Keywords: patch

Created on 2022-02-12 19:10 by JelleZijlstra, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 31301 merged JelleZijlstra, 2022-02-12 19:18
PR 31473 merged miss-islington, 2022-02-21 15:46
PR 31474 merged miss-islington, 2022-02-21 15:46
Messages (5)
msg413141 - (view) Author: Jelle Zijlstra (JelleZijlstra) * (Python committer) Date: 2022-02-12 19:10
>>> None.__bool__.__doc__
'self != 0'

This isn't true, since None does not equal 0. I suggest rewording it to "True if self else False".
msg413505 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2022-02-18 19:43
There is no object.__bool__.  None.__bool__.__doc__ appears to be an accidental copy of bool/int/float/complex.__bool__.__doc__.  It should just be 'False'.
msg413628 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2022-02-21 02:36
For whatever reason, all builtins with a __bool__ method appear to share the same docstring.  For example,

>>> range.__bool__.__doc__
'self != 0'
>>> bool(range(0))
False
>>> bool(range(1))
True

The concrete collection classes have their lengths stored internally so bool use that via len(self).  But len(range) != 0 iff stop != start.
msg413660 - (view) Author: miss-islington (miss-islington) Date: 2022-02-21 17:18
New changeset c596ecbf821843de0e044f0d4da34c6b49a06907 by Miss Islington (bot) in branch '3.10':
[3.10] bpo-46732: fix __bool__ docstring (GH-31301) (GH-31473)
https://github.com/python/cpython/commit/c596ecbf821843de0e044f0d4da34c6b49a06907
msg413661 - (view) Author: miss-islington (miss-islington) Date: 2022-02-21 17:18
New changeset 8eb18d842c37c37c1f9316c7e171aad36e875b9a by Miss Islington (bot) in branch '3.9':
[3.9] bpo-46732: fix __bool__ docstring (GH-31301) (GH-31474)
https://github.com/python/cpython/commit/8eb18d842c37c37c1f9316c7e171aad36e875b9a
History
Date User Action Args
2022-04-11 14:59:56adminsetgithub: 90888
2022-02-21 17:19:35JelleZijlstrasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2022-02-21 17:18:59miss-islingtonsetmessages: + msg413661
2022-02-21 17:18:56miss-islingtonsetmessages: + msg413660
2022-02-21 15:46:55miss-islingtonsetpull_requests: + pull_request29605
2022-02-21 15:46:15miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request29604
2022-02-21 02:36:33terry.reedysetmessages: + msg413628
title: None.__bool__ docstring is wrong -> Builtin __bool__ docstrings are wrong
2022-02-18 19:43:57terry.reedysetnosy: + terry.reedy

messages: + msg413505
title: object.__bool__ docstring is wrong -> None.__bool__ docstring is wrong
2022-02-12 19:18:54JelleZijlstrasetkeywords: + patch
stage: patch review
pull_requests: + pull_request29460
2022-02-12 19:10:01JelleZijlstracreate