Use is/is not to check for None in python code.
authorLancelot SIX <lsix@lancelotsix.com>
Mon, 7 Jun 2021 22:14:55 +0000 (23:14 +0100)
committerLancelot SIX <lsix@lancelotsix.com>
Tue, 8 Jun 2021 22:49:05 +0000 (23:49 +0100)
commitf9e59d060fbdad57f8d927cf51eade0d46b47e12
tree1648300094500bb1e5c11d84c92e54fe770902af
parent122373f7f25946cfc51de9e19ba1d173195f9910
Use is/is not to check for None in python code.

While reviewing a patch sent to the mailing list, I noticed there are few
places where python code checks if a variable is 'None' or not by using the
comparison operators '==' and '!='.  PEP8[1], which is used as coding standard
in GDB coding standards, recommends using 'is' / 'is not' when comparing to a
singleton such as 'None'.

This patch proposes to change the instances of '== None' by 'is None' and
'!= None' by 'is not None'.

[1] https://www.python.org/dev/peps/pep-0008/

gdb/doc/ChangeLog:

* python.texi (Writing a Pretty-Printer): Use 'is None' instead of
'== None'.

gdb/ChangeLog:

* python/lib/gdb/FrameDecorator.py (FrameDecorator): Use 'is None' instead of
'== None'.
(FrameVars): Use 'is not None' instead of '!= None'.
* python/lib/gdb/command/frame_filters.py (SetFrameFilterPriority): Use 'is None'
instead of '== None' and 'is not None' instead of '!= None'.

gdb/testsuite/ChangeLog:

* gdb.base/premature-dummy-frame-removal.py (TestUnwinder): Use
'is None' instead of '== None' and 'is not None' instead of
'!= None'.
* gdb.python/py-frame-args.py (lookup_function): Same.
* gdb.python/py-framefilter-invalidarg.py (Reverse_Function): Same.
* gdb.python/py-framefilter.py (Reverse_Function): Same.
* gdb.python/py-nested-maps.py (lookup_function): Same.
* gdb.python/py-objfile-script-gdb.py (lookup_function): Same.
* gdb.python/py-prettyprint.py (lookup_function): Same.
* gdb.python/py-section-script.py (lookup_function): Same.
* gdb.python/py-unwind-inline.py (dummy_unwinder): Same.
* gdb.python/python.exp: Same.
* gdb.rust/pp.py (lookup_function): Same.
17 files changed:
gdb/ChangeLog
gdb/doc/ChangeLog
gdb/doc/python.texi
gdb/python/lib/gdb/FrameDecorator.py
gdb/python/lib/gdb/command/frame_filters.py
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/premature-dummy-frame-removal.py
gdb/testsuite/gdb.python/py-frame-args.py
gdb/testsuite/gdb.python/py-framefilter-invalidarg.py
gdb/testsuite/gdb.python/py-framefilter.py
gdb/testsuite/gdb.python/py-nested-maps.py
gdb/testsuite/gdb.python/py-objfile-script-gdb.py
gdb/testsuite/gdb.python/py-prettyprint.py
gdb/testsuite/gdb.python/py-section-script.py
gdb/testsuite/gdb.python/py-unwind-inline.py
gdb/testsuite/gdb.python/python.exp
gdb/testsuite/gdb.rust/pp.py