Fix incorrect use of 'is' operator for comparison in python/lib/gdb/command/prompt.py
Commit Message
Noticed this while searching for similar issues in the Chromium codebase.
Hopefully I managed to format the patch correctly.
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(-)
Comments
On 2019-05-04 6:25 a.m., Raul Tambre via gdb-patches wrote:
> Noticed this while searching for similar issues in the Chromium codebase.
> Hopefully I managed to format the patch correctly.
Good catch, thanks! I have pushed the patch, it is small enough not to require
a copyright assignment.
The patch was correctly formatted, I was able to git-apply it as-is. How did you
generate it? The most reliable way is to use git-send-email, which sends the patch
directly as an email, or as a second choice git-format-patch, which produces a .patch
file that you can then attach. The patches produced by these two commands can be
easily applied by the person on the other side using git-am.
Simon
@@ -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