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: Do not use the equality operators with None
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: serhiy.storchaka, terry.reedy
Priority: normal Keywords: patch

Created on 2021-08-31 11:47 by serhiy.storchaka, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 28087 merged serhiy.storchaka, 2021-08-31 11:50
PR 28092 merged serhiy.storchaka, 2021-08-31 14:03
PR 28093 merged serhiy.storchaka, 2021-08-31 14:07
Messages (4)
msg400715 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-08-31 11:47
There are few uses of operators "==" and "!=" with None in the stdlib (against more than 8000 uses of "is" and "is not"). It is very uncommon writing, contradicts PEP 8, and is not safe in general.

One bug was found -- using "==" instead of assignment (issue45059).
msg400734 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-08-31 14:00
New changeset 3c65457156d87e55010507d616b4eecb7a02883d by Serhiy Storchaka in branch 'main':
bpo-45060: Get rid of few uses of the equality operators with None (GH-28087)
https://github.com/python/cpython/commit/3c65457156d87e55010507d616b4eecb7a02883d
msg400815 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-09-01 06:51
New changeset e09dd8aafd6f9aef03945c417267806d47084a5d by Serhiy Storchaka in branch '3.9':
[3.9] bpo-45060: Get rid of few uses of the equality operators with None (GH-28087). (GH-28093)
https://github.com/python/cpython/commit/e09dd8aafd6f9aef03945c417267806d47084a5d
msg401028 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-09-04 01:13
New changeset e2b29304137e6253b7bb89c180ef5d113d60b4eb by Serhiy Storchaka in branch '3.10':
[3.10] bpo-45060: Get rid of few uses of the equality operators with None (GH-28087). (GH-28092)
https://github.com/python/cpython/commit/e2b29304137e6253b7bb89c180ef5d113d60b4eb
History
Date User Action Args
2022-04-11 14:59:49adminsetgithub: 89223
2021-09-04 01:14:15terry.reedysetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-09-04 01:13:18terry.reedysetnosy: + terry.reedy
messages: + msg401028
2021-09-01 06:51:08serhiy.storchakasetmessages: + msg400815
2021-08-31 14:07:33serhiy.storchakasetpull_requests: + pull_request26536
2021-08-31 14:03:56serhiy.storchakasetpull_requests: + pull_request26535
2021-08-31 14:00:08serhiy.storchakasetmessages: + msg400734
2021-08-31 11:50:13serhiy.storchakasetkeywords: + patch
stage: patch review
pull_requests: + pull_request26530
2021-08-31 11:47:38serhiy.storchakacreate