Some Python 3 fixes
authorSimon Marchi <simon.marchi@ericsson.com>
Wed, 15 Apr 2015 15:54:33 +0000 (11:54 -0400)
committerSimon Marchi <simon.marchi@ericsson.com>
Wed, 15 Apr 2015 15:54:33 +0000 (11:54 -0400)
Some missing parentheses and one itertools.imap (Py2) vs map (Py3) issue.

gdb/ChangeLog:

* python/lib/gdb/command/unwinders.py: Add parentheses.

gdb/testsuite/ChangeLog:

* gdb.python/py-framefilter.py (ErrorFilter.filter): Use map function
if itertools.imap is not present.
* gdb.python/py-objfile.exp: Add parentheses.
* gdb.python/py-type.exp: Same.
* gdb.python/py-unwind-maint.py: Same.

gdb/ChangeLog
gdb/python/lib/gdb/command/unwinders.py
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.python/py-framefilter.py
gdb/testsuite/gdb.python/py-objfile.exp
gdb/testsuite/gdb.python/py-type.exp
gdb/testsuite/gdb.python/py-unwind-maint.py

index a4befb4506370565ddfbf131e33cfcb2a8c9b80a..033def0ff4a9e699ca02915d1ab183c84b7506b8 100644 (file)
@@ -1,3 +1,7 @@
+2015-04-15  Simon Marchi  <simon.marchi@ericsson.com>
+
+       * python/lib/gdb/command/unwinders.py: Add parentheses.
+
 2015-04-15  Yao Qi  <yao.qi@linaro.org>
 
        * arm-linux-tdep.c (arm_linux_copy_svc): Update debug message.
index 8530b35d438159c8285a2ec0f81a7d4583ebd554..1a5aed9c3513d4c56c2dbc30ce340080d835debe 100644 (file)
@@ -83,7 +83,7 @@ class InfoUnwinder(gdb.Command):
         """
         if not unwinders:
             return
-        print title
+        print(title)
         for unwinder in unwinders:
             if name_re.match(unwinder.name):
                 print("  %s%s" % (unwinder.name,
index 9fa680d0d4c83c0339c6feab9b546f43c3296a33..91fd9a917ac3a2ebcead3eb2e5c0947066e17691 100644 (file)
@@ -1,3 +1,11 @@
+2015-04-15  Simon Marchi  <simon.marchi@ericsson.com>
+
+       * gdb.python/py-framefilter.py (ErrorFilter.filter): Use map function
+       if itertools.imap is not present.
+       * gdb.python/py-objfile.exp: Add parentheses.
+       * gdb.python/py-type.exp: Same.
+       * gdb.python/py-unwind-maint.py: Same.
+
 2015-04-15  Yao Qi  <yao.qi@linaro.org>
 
        * gdb.dwarf2/dynarr-ptr.exp (assemble): Use $ptr_size instead
index 0de026c7042ceb343878f62c692396ad3c9919e1..1e5b2b3c967b599270975ffe51bb2a278e3a0b93 100644 (file)
@@ -145,7 +145,12 @@ class ErrorFilter():
         gdb.frame_filters [self.name] = self
 
     def filter(self, frame_iter):
-        return itertools.imap(ErrorInName, frame_iter)
+        # Python 3.x moved the itertools.imap functionality to map(),
+        # so check if it is available.
+        if hasattr(itertools, "imap"):
+            return itertools.imap (ErrorInName, frame_iter)
+        else:
+            return map(ErrorInName, frame_iter)
 
 FrameFilter()
 FrameElider()
index b53f5e3bae66a32b121d45559e266e5bf2a6b3df..4de20c5013259277cfeca011190377b5a9500a2e 100644 (file)
@@ -88,9 +88,9 @@ if { [gdb_unload] < 0 } {
     return -1
 }
 
-gdb_test "python print objfile.filename" "None" \
+gdb_test "python print(objfile.filename)" "None" \
     "objfile.filename after objfile is unloaded"
-gdb_test "python print objfile.username" "None" \
+gdb_test "python print(objfile.username)" "None" \
     "objfile.username after objfile is unloaded"
 
 # Now build another copy of the testcase, this time without debug info.
index c4c8d9f92aa292678932d60b5d16e70944cc6e01..9e522f23221d5d80518c53fc6f521c94d2ca9280 100644 (file)
@@ -247,10 +247,10 @@ restart_gdb "${binfile}"
 # Skip all tests if Python scripting is not enabled.
 if { [skip_python_tests] } { continue }
 
-gdb_test "python print gdb.lookup_type('char').array(1, 0)" \
+gdb_test "python print(gdb.lookup_type('char').array(1, 0))" \
     "char \\\[0\\\]"
 
-gdb_test "python print gdb.lookup_type('char').array(1, -1)" \
+gdb_test "python print(gdb.lookup_type('char').array(1, -1))" \
     "Array length must not be negative.*"
 
 with_test_prefix "lang_c" {
index f8c627719b1a304c690afbad7cfeb5d62eef87bd..288fe071b349873530ddc0ccd7fe28f4204954ce 100644 (file)
@@ -24,7 +24,7 @@ class TestGlobalUnwinder(Unwinder):
         super(TestGlobalUnwinder, self).__init__("global_unwinder")
 
     def __call__(self, unwinder_info):
-        print "%s called" % self.name
+        print("%s called" % self.name)
         return None
 
 class TestProgspaceUnwinder(Unwinder):
@@ -32,7 +32,7 @@ class TestProgspaceUnwinder(Unwinder):
         super(TestProgspaceUnwinder, self).__init__("%s_ps_unwinder" % name)
 
     def __call__(self, unwinder_info):
-        print "%s called" % self.name
+        print("%s called" % self.name)
         return None
 
 class TestObjfileUnwinder(Unwinder):
@@ -40,7 +40,7 @@ class TestObjfileUnwinder(Unwinder):
         super(TestObjfileUnwinder, self).__init__("%s_obj_unwinder" % name)
 
     def __call__(self, unwinder_info):
-        print "%s called" % self.name
+        print("%s called" % self.name)
         return None
 
 
@@ -56,4 +56,4 @@ if not saw_runtime_error:
 gdb.unwinder.register_unwinder(None, TestGlobalUnwinder(), replace=True)
 gdb.unwinder.register_unwinder(gdb.current_progspace(),
                                TestProgspaceUnwinder("py_unwind_maint"))
-print "Python script imported"
+print("Python script imported")