[PATCH] Fix incorrect use of 'is' operator for comparison in python/lib/gdb/command/prompt.py

Raul Tambre via gdb-patches gdb-patches@sourceware.org
Sat May 4 10:25:00 GMT 2019


Noticed this while searching for similar issues in the Chromium codebase.
Hopefully I managed to format the patch correctly.

-------------- next part --------------
Fix incorrect use of 'is' operator for comparison in python/lib/gdb/command/prompt.py

The 'is' operator is not meant to be used for comparisons. It currently working is an implementation detail of CPython.
CPython 3.8 has added a SyntaxWarning for this.

gdb/ChangeLog:

2019-05-04  Raul Tambre <raul@tambre.ee>

	* python/lib/gdb/prompt.py: Fix incorrect use of 'is' operator for
	comparison.

---
 gdb/python/lib/gdb/command/prompt.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gdb/python/lib/gdb/command/prompt.py b/gdb/python/lib/gdb/command/prompt.py
index 3d662a7d..04b9e49c 100644
--- a/gdb/python/lib/gdb/command/prompt.py
+++ b/gdb/python/lib/gdb/command/prompt.py
@@ -45,7 +45,7 @@ The currently defined substitutions are:
         self.hook_set = False
 
     def get_show_string (self, pvalue):
-        if self.value is not '':
+        if self.value:
            return "The extended prompt is: " + self.value
         else:
            return "The extended prompt is not set."
@@ -57,7 +57,7 @@ The currently defined substitutions are:
         return ""
 
     def before_prompt_hook(self, current):
-        if self.value is not '':
+        if self.value:
             return gdb.prompt.substitute_prompt(self.value)
         else:
             return None
-- 
2.21.0.windows.1



More information about the Gdb-patches mailing list