This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Current gdb python errors on python-2.4


I think gdb in cvs has some python that is not supported by python-2.4
(e.g. on centos5) - code like 'except Exception as e:'.

This leads to startup warnings like:

    [jules@vm-centos5 ~]$ ./gdb_cvs_dir/src/gdb/gdb -data-directory gdb_cvs_dir/src/gdb/data-directory
    Traceback (most recent call last):
      File "/home/jules/gdb_cvs_dir/src/gdb/data-directory/python/gdb/__init__.py", line 105, in auto_load_packages
        __import__(modname)
      File "gdb_cvs_dir/src/gdb/data-directory/python/gdb/command/frame_filters.py", line 82
        except Exception as e:
                          ^
    SyntaxError: invalid syntax

    GNU gdb (GDB) 7.6.50.20130607-cvs
    Copyright (C) 2013 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
    and "show warranty" for details.
    This GDB was configured as "i686-pc-linux-gnu".
    Type "show configuration" for configuration details.
    For bug reporting instructions, please see:
    <http://www.gnu.org/software/gdb/bugs/>.
    (gdb) 

- and subsequent use of python from within gdb fails.

I think simply replacing the 'as' with a comma will allow the code to
work with all python versions ?

Here's a patch that works for me:

Index: gdb/python/lib/gdb/command/frame_filters.py
===================================================================
RCS file: /cvs/src/src/gdb/python/lib/gdb/command/frame_filters.py,v
retrieving revision 1.1
diff -u -r1.1 frame_filters.py
--- gdb/python/lib/gdb/command/frame_filters.py 10 May 2013 10:26:02 -0000      1.1
+++ gdb/python/lib/gdb/command/frame_filters.py 9 Jun 2013 02:55:29 -0000
@@ -79,7 +79,7 @@
                         str(gdb.frames.get_priority(frame_filter[1])))
                     enabled = '{:<7}'.format(
                         self.enabled_string(gdb.frames.get_enabled(frame_filter[1])))
-                except Exception as e:
+                except Exception, e:
                     print("  Error printing filter '"+name+"': "+str(e))
                 else:
                     print("  %s  %s  %s" % (priority, enabled, name))
@@ -445,7 +445,7 @@
         list_name = command_tuple[0]
         try:
             priority = self.get_filter_priority(list_name, filter_name);
-        except Exception as e:
+        except Exception, e:
             print("Error printing filter priority for '"+name+"':"+str(e))
         else:
             print("Priority of filter '" + filter_name + "' in list '" \

Index: gdb/testsuite/gdb.python/py-finish-breakpoint.py
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-finish-breakpoint.py,v
retrieving revision 1.5
diff -u -r1.5 py-finish-breakpoint.py
--- gdb/testsuite/gdb.python/py-finish-breakpoint.py    1 Jan 2013 06:41:26 -0000       1.5
+++ gdb/testsuite/gdb.python/py-finish-breakpoint.py    9 Jun 2013 02:55:30 -0000
@@ -42,7 +42,7 @@
         self.count += 1
         try:
                 TestFinishBreakpoint (gdb.newest_frame (), self.count)
-        except ValueError as e:
+        except ValueError, e:
                 print (e)
         return False
 
@@ -69,7 +69,7 @@
         def stop(self):
                 try:
                         SimpleFinishBreakpoint (gdb.newest_frame ())
-                except ValueError as e:
+                except ValueError, e:
                         print (e)
                 return False


Thanks,

- Julian

-- 
http://op59.net/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]