[binutils-gdb] gdb/testsuite: use "is" for type comparison in Python files

Simon Marchi simark@sourceware.org
Thu Oct 30 16:26:58 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0e529fc9c7f5b2f1838dd4ded84fe06735288ff0

commit 0e529fc9c7f5b2f1838dd4ded84fe06735288ff0
Author: Simon Marchi <simon.marchi@efficios.com>
Date:   Wed Oct 29 13:49:18 2025 -0400

    gdb/testsuite: use "is" for type comparison in Python files
    
    Fix flake8 warnings like:
    
        gdb/testsuite/gdb.python/py-unwind.py:253:20: E721 do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()`
    
    Change-Id: I506c0874bba88aa418757d94168992bf4ec677f8
    Approved-By: Tom Tromey <tom@tromey.com>

Diff:
---
 gdb/testsuite/gdb.python/py-missing-objfile.py | 6 +++---
 gdb/testsuite/gdb.python/py-unwind.py          | 2 +-
 gdb/testsuite/gdb.python/source2.py            | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/gdb/testsuite/gdb.python/py-missing-objfile.py b/gdb/testsuite/gdb.python/py-missing-objfile.py
index bdd7a599b63..dab34168530 100644
--- a/gdb/testsuite/gdb.python/py-missing-objfile.py
+++ b/gdb/testsuite/gdb.python/py-missing-objfile.py
@@ -41,10 +41,10 @@ handler_last_filename = None
 # A helper function that makes some assertions about the arguments
 # passed to a MissingObjfileHandler.__call__() method.
 def check_args(pspace, buildid, filename):
-    assert type(filename) == str
+    assert type(filename) is str
     assert filename != ""
-    assert type(pspace) == gdb.Progspace
-    assert type(buildid) == str
+    assert type(pspace) is gdb.Progspace
+    assert type(buildid) is str
     assert buildid != ""
 
 
diff --git a/gdb/testsuite/gdb.python/py-unwind.py b/gdb/testsuite/gdb.python/py-unwind.py
index 183c6b1eb67..50c6d55cac0 100644
--- a/gdb/testsuite/gdb.python/py-unwind.py
+++ b/gdb/testsuite/gdb.python/py-unwind.py
@@ -250,7 +250,7 @@ class validating_unwinder(Unwinder):
 
         for key, value in info.items():
             assert key in old_info, key + " not in old_info"
-            assert type(value) == type(old_info[key])
+            assert type(value) is type(old_info[key])
             if isinstance(value, gdb.Block):
                 assert value.start == old_info[key].start
                 assert value.end == old_info[key].end
diff --git a/gdb/testsuite/gdb.python/source2.py b/gdb/testsuite/gdb.python/source2.py
index 7ca0bb2fe98..59ac6f6a6b3 100644
--- a/gdb/testsuite/gdb.python/source2.py
+++ b/gdb/testsuite/gdb.python/source2.py
@@ -16,6 +16,6 @@
 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Make sure __file__ is defined.
-assert type(__file__) == str
+assert type(__file__) is str
 
 print("y%ss" % "e")


More information about the Gdb-cvs mailing list