aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorLancelot SIX <lsix@lancelotsix.com>2021-06-07 23:14:55 +0100
committerLancelot SIX <lsix@lancelotsix.com>2021-06-08 23:49:05 +0100
commitf9e59d060fbdad57f8d927cf51eade0d46b47e12 (patch)
tree1648300094500bb1e5c11d84c92e54fe770902af /gdb/python
parent122373f7f25946cfc51de9e19ba1d173195f9910 (diff)
downloadgdb-f9e59d060fbdad57f8d927cf51eade0d46b47e12.zip
gdb-f9e59d060fbdad57f8d927cf51eade0d46b47e12.tar.gz
gdb-f9e59d060fbdad57f8d927cf51eade0d46b47e12.tar.bz2
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.
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/lib/gdb/FrameDecorator.py10
-rw-r--r--gdb/python/lib/gdb/command/frame_filters.py4
2 files changed, 7 insertions, 7 deletions
diff --git a/gdb/python/lib/gdb/FrameDecorator.py b/gdb/python/lib/gdb/FrameDecorator.py
index 1f4b2ca..69a0a9a 100644
--- a/gdb/python/lib/gdb/FrameDecorator.py
+++ b/gdb/python/lib/gdb/FrameDecorator.py
@@ -117,7 +117,7 @@ class FrameDecorator(object):
# address. If GDB detects an integer value from this function
# it will attempt to find the function name from minimal
# symbols via its own internal functions.
- if func == None:
+ if func is None:
pc = frame.pc()
return pc
@@ -270,7 +270,7 @@ class FrameVars(object):
except RuntimeError:
block = None
- while block != None:
+ while block is not None:
if block.is_global or block.is_static:
break
for sym in block:
@@ -295,12 +295,12 @@ class FrameVars(object):
except RuntimeError:
block = None
- while block != None:
- if block.function != None:
+ while block is not None:
+ if block.function is not None:
break
block = block.superblock
- if block != None:
+ if block is not None:
for sym in block:
if not sym.is_argument:
continue
diff --git a/gdb/python/lib/gdb/command/frame_filters.py b/gdb/python/lib/gdb/command/frame_filters.py
index 91e8ca2..97488ca 100644
--- a/gdb/python/lib/gdb/command/frame_filters.py
+++ b/gdb/python/lib/gdb/command/frame_filters.py
@@ -372,7 +372,7 @@ class SetFrameFilterPriority(gdb.Command):
def invoke(self, arg, from_tty):
command_tuple = self._parse_pri_arg(arg)
- if command_tuple != None:
+ if command_tuple is not None:
self._set_filter_priority(command_tuple)
@@ -453,7 +453,7 @@ class ShowFrameFilterPriority(gdb.Command):
def invoke(self, arg, from_tty):
command_tuple = self._parse_pri_arg(arg)
- if command_tuple == None:
+ if command_tuple is None:
return
filter_name = command_tuple[1]
list_name = command_tuple[0]