This is the mail archive of the mailing list for the Archer 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]

[python] Trivial filename check in python/lib/gdb/command/

Right now if one does not specify a fiilename with "save breakpoints" command, this error message is produced:

(gdb) save breakpoints
Traceback (most recent call last):
File "/home/pmuldoon/python/archer/gdb/python/lib/gdb/command/", line 44, in invoke
with open (arg.strip (), 'w') as f:
AttributeError: 'NoneType' object has no attribute 'strip'
Error occurred in Python command: 'NoneType' object has no attribute 'strip'

Trivial change to check is args is None and if so, produce a slightly better message:

(pg-gdb) save breakpoints
Traceback (most recent call last):
File "/home/pmuldoon/python/archer/gdb/python/lib/gdb/command/", line 45, in invoke
raise RuntimeError, 'No filename specified'
RuntimeError: No filename specified
Error occurred in Python command.

I thought about adding write permissions checks too, but decided against it. Can add if needed.


diff --git a/gdb/python/lib/gdb/command/ b/gdb/python/lib/gdb/command/
index a2bed0d..14a27f7 100644
--- a/gdb/python/lib/gdb/command/
+++ b/gdb/python/lib/gdb/command/
@@ -1,6 +1,6 @@
 # Save breakpoints.
-# Copyright (C) 2008 Free Software Foundation, Inc.
+# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -41,6 +41,8 @@ The breakpoints can be restored using the 'source' command."""
         bps = gdb.breakpoints ()
         if bps is None:
             raise RuntimeError, 'No breakpoints to save'
+        if arg is None:
+            raise RuntimeError, 'No filename specified'
         with open (arg.strip (), 'w') as f:
             for bp in bps:
                 print >> f, "break", bp.location,

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