aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
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/testsuite
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/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog16
-rw-r--r--gdb/testsuite/gdb.base/premature-dummy-frame-removal.py4
-rw-r--r--gdb/testsuite/gdb.python/py-frame-args.py2
-rw-r--r--gdb/testsuite/gdb.python/py-framefilter-invalidarg.py2
-rw-r--r--gdb/testsuite/gdb.python/py-framefilter.py2
-rw-r--r--gdb/testsuite/gdb.python/py-nested-maps.py4
-rw-r--r--gdb/testsuite/gdb.python/py-objfile-script-gdb.py2
-rw-r--r--gdb/testsuite/gdb.python/py-prettyprint.py4
-rw-r--r--gdb/testsuite/gdb.python/py-section-script.py2
-rw-r--r--gdb/testsuite/gdb.python/py-unwind-inline.py2
-rw-r--r--gdb/testsuite/gdb.python/python.exp2
-rw-r--r--gdb/testsuite/gdb.rust/pp.py2
12 files changed, 30 insertions, 14 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 51abd0e..92894d6 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,19 @@
+2021-06-08 Lancelot Six <lsix@lancelotsix.com>
+
+ * 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.
+
2021-06-08 Tom de Vries <tdevries@suse.de>
* lib/gdb.exp (multi_line): Require more than one argument.
diff --git a/gdb/testsuite/gdb.base/premature-dummy-frame-removal.py b/gdb/testsuite/gdb.base/premature-dummy-frame-removal.py
index 3193665..fbad6d4 100644
--- a/gdb/testsuite/gdb.base/premature-dummy-frame-removal.py
+++ b/gdb/testsuite/gdb.base/premature-dummy-frame-removal.py
@@ -46,10 +46,10 @@ class TestUnwinder(Unwinder):
sp = pending_frame.read_register(sp_desc)
block = gdb.block_for_pc(int(pc))
- if block == None:
+ if block is None:
return None
func = block.function
- if func == None:
+ if func is None:
return None
if str(func) != "break_bt_here":
return None
diff --git a/gdb/testsuite/gdb.python/py-frame-args.py b/gdb/testsuite/gdb.python/py-frame-args.py
index 32d7204..59dd14d 100644
--- a/gdb/testsuite/gdb.python/py-frame-args.py
+++ b/gdb/testsuite/gdb.python/py-frame-args.py
@@ -53,7 +53,7 @@ def lookup_function(val):
# Get the type name.
typename = type.tag
- if typename == None:
+ if typename is None:
return None
# Iterate over local dictionary of types to determine
diff --git a/gdb/testsuite/gdb.python/py-framefilter-invalidarg.py b/gdb/testsuite/gdb.python/py-framefilter-invalidarg.py
index 609ff80..20af516 100644
--- a/gdb/testsuite/gdb.python/py-framefilter-invalidarg.py
+++ b/gdb/testsuite/gdb.python/py-framefilter-invalidarg.py
@@ -28,7 +28,7 @@ class Reverse_Function(FrameDecorator):
def function(self):
fname = str(self.fobj.function())
- if fname == None or fname == "":
+ if not fname:
return None
if fname == "end_func":
extra = self.fobj.inferior_frame().read_var("str").string()
diff --git a/gdb/testsuite/gdb.python/py-framefilter.py b/gdb/testsuite/gdb.python/py-framefilter.py
index ce5a35d..8058f61 100644
--- a/gdb/testsuite/gdb.python/py-framefilter.py
+++ b/gdb/testsuite/gdb.python/py-framefilter.py
@@ -28,7 +28,7 @@ class Reverse_Function(FrameDecorator):
def function(self):
fname = str(self.fobj.function())
- if fname == None or fname == "":
+ if not fname:
return None
if fname == "end_func":
extra = self.fobj.inferior_frame().read_var("str").string()
diff --git a/gdb/testsuite/gdb.python/py-nested-maps.py b/gdb/testsuite/gdb.python/py-nested-maps.py
index 163fc86..2848347 100644
--- a/gdb/testsuite/gdb.python/py-nested-maps.py
+++ b/gdb/testsuite/gdb.python/py-nested-maps.py
@@ -88,7 +88,7 @@ def lookup_function(val):
# Get the type name.
typename = type.tag
- if typename == None:
+ if typename is None:
return None
# Iterate over local dictionary of types to determine
@@ -109,7 +109,7 @@ def lookup_typedefs_function(val):
# Get the type.
type = val.type
- if type == None or type.name == None or type.code != gdb.TYPE_CODE_TYPEDEF:
+ if type is None or type.name is None or type.code != gdb.TYPE_CODE_TYPEDEF:
return None
# Iterate over local dictionary of typedef types to determine if a
diff --git a/gdb/testsuite/gdb.python/py-objfile-script-gdb.py b/gdb/testsuite/gdb.python/py-objfile-script-gdb.py
index 88372e4..45d036c 100644
--- a/gdb/testsuite/gdb.python/py-objfile-script-gdb.py
+++ b/gdb/testsuite/gdb.python/py-objfile-script-gdb.py
@@ -42,7 +42,7 @@ def lookup_function(val):
# Get the type name.
typename = type.tag
- if typename == None:
+ if typename is None:
return None
# Iterate over local dictionary of types to determine
diff --git a/gdb/testsuite/gdb.python/py-prettyprint.py b/gdb/testsuite/gdb.python/py-prettyprint.py
index 84dbc3b..89ffc0f 100644
--- a/gdb/testsuite/gdb.python/py-prettyprint.py
+++ b/gdb/testsuite/gdb.python/py-prettyprint.py
@@ -314,7 +314,7 @@ def lookup_function(val):
# Get the type name.
typename = type.tag
- if typename == None:
+ if typename is None:
return None
# Iterate over local dictionary of types to determine
@@ -344,7 +344,7 @@ def lookup_typedefs_function(val):
# Get the type.
type = val.type
- if type == None or type.name == None or type.code != gdb.TYPE_CODE_TYPEDEF:
+ if type is None or type.name is None or type.code != gdb.TYPE_CODE_TYPEDEF:
return None
# Iterate over local dictionary of typedef types to determine if a
diff --git a/gdb/testsuite/gdb.python/py-section-script.py b/gdb/testsuite/gdb.python/py-section-script.py
index aac70a0..8562e52 100644
--- a/gdb/testsuite/gdb.python/py-section-script.py
+++ b/gdb/testsuite/gdb.python/py-section-script.py
@@ -42,7 +42,7 @@ def lookup_function(val):
# Get the type name.
typename = type.tag
- if typename == None:
+ if typename is None:
return None
# Iterate over local dictionary of types to determine
diff --git a/gdb/testsuite/gdb.python/py-unwind-inline.py b/gdb/testsuite/gdb.python/py-unwind-inline.py
index 3042472..2892f41 100644
--- a/gdb/testsuite/gdb.python/py-unwind-inline.py
+++ b/gdb/testsuite/gdb.python/py-unwind-inline.py
@@ -45,7 +45,7 @@ class dummy_unwinder(Unwinder):
def get_regs(self, pending_frame):
"""Return a list of register names that should be read. Only
gathers the list once, then caches the result."""
- if self.regs != None:
+ if self.regs is not None:
return self.regs
# Collect the names of all registers to read.
diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp
index c7d879e..d9fd60f 100644
--- a/gdb/testsuite/gdb.python/python.exp
+++ b/gdb/testsuite/gdb.python/python.exp
@@ -192,7 +192,7 @@ gdb_test "python print (a)" ".*aliases -- User-defined aliases of other commands
# Test PR 12212, using InfThread.selected_thread() when no inferior is
# loaded.
gdb_py_test_silent_cmd "python nothread = gdb.selected_thread()" "Attempt to aquire thread with no inferior" 1
-gdb_test "python print (nothread == None)" "True" "ensure that no threads are returned"
+gdb_test "python print (nothread is None)" "True" "ensure that no threads are returned"
gdb_test_multiline "register atexit function" \
"python" "" \
diff --git a/gdb/testsuite/gdb.rust/pp.py b/gdb/testsuite/gdb.rust/pp.py
index 57c8cc3..a78e300 100644
--- a/gdb/testsuite/gdb.rust/pp.py
+++ b/gdb/testsuite/gdb.rust/pp.py
@@ -38,7 +38,7 @@ def lookup_function(val):
# Get the type name.
typename = type.tag
- if typename == None:
+ if typename is None:
return None
if typename == "pp::Inner":