Skip to contentSkip to conversation

scripts/gdb: fix python 3.8 SyntaxWarning

PATCH Applied Nick Desaulniers 2 participants 2 messages Aug 5, 2020 GDB kernel debugging helper scripts

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scripts/gdb: fix python 3.8 SyntaxWarning

Fixes the observed warnings:
scripts/gdb/linux/rbtree.py:20: SyntaxWarning: "is" with a literal. Did you mean "=="?
if node is 0:
scripts/gdb/linux/rbtree.py:36: SyntaxWarning: "is" with a literal. Did you mean "=="?
if node is 0:

It looks like this is a new warning added in Python 3.8. I've only seen this once after adding the add-auto-load-safe-path rule to my ~/.gdbinit for a new tree.

Cc Stephen Boyd <[email protected]>
Fixes commit 449ca0c95ea2 ("scripts/gdb: add rb tree iterating utilities")
---
 scripts/gdb/linux/rbtree.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/gdb/linux/rbtree.py +2 -2
index c4b991607917..fe462855eefd 100644
@@ -17,7 +17,7 @@ def rb_first(root):
         raise gdb.GdbError("Must be struct rb_root not {}".format(root.type))
 
     node = root['rb_node']
-    if node is 0:
+    if node == 0:
         return None
 
     while node['rb_left']:
@@ -33,7 +33,7 @@ def rb_last(root):
         raise gdb.GdbError("Must be struct rb_root not {}".format(root.type))
 
     node = root['rb_node']
-    if node is 0:
+    if node == 0:
         return None
 
     while node['rb_right']:
Signature · 1 line
2.28.0.163.g6104cc2f0b6-goog
Reviewed-by on v1 1/1
#1 lore raw

Quoting Nick Desaulniers (2020-08-05 15:50:14)

Quoted 12 lines

Fixes the observed warnings:
scripts/gdb/linux/rbtree.py:20: SyntaxWarning: "is" with a literal. Did you mean "=="?
if node is 0:
scripts/gdb/linux/rbtree.py:36: SyntaxWarning: "is" with a literal. Did you mean "=="?
if node is 0:

It looks like this is a new warning added in Python 3.8. I've only seen this once after adding the add-auto-load-safe-path rule to my ~/.gdbinit for a new tree.

Quoted 5 lines
Cc Stephen Boyd <[email protected]>
Fixes commit 449ca0c95ea2 ("scripts/gdb: add rb tree iterating utilities")

---