summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-07-01 10:59:30 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-07-01 10:59:30 (GMT)
commitc9e07a3ec8c48ca833f57286474226e2e82f5214 (patch)
tree1836e6be3b2b827b7ab169e031d9673dcfa2749b /Tools
parent4497445b3fd6d246f47e92ce5118ceb76e8b2ab2 (diff)
parentd57c5c8a3adc7ec3cd0b41b5f7a1a1f72eeec70e (diff)
downloadcpython-c9e07a3ec8c48ca833f57286474226e2e82f5214.zip
cpython-c9e07a3ec8c48ca833f57286474226e2e82f5214.tar.gz
cpython-c9e07a3ec8c48ca833f57286474226e2e82f5214.tar.bz2
(merge 3.2) libpython.py (gdb) now catchs IOError in py-list and py-bt commands
py-list displays the error. py-bt ignores the error (the filename and line number is already displayed).
Diffstat (limited to 'Tools')
-rw-r--r--Tools/gdb/libpython.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/Tools/gdb/libpython.py b/Tools/gdb/libpython.py
index f3cb1b0..ca1dc60 100644
--- a/Tools/gdb/libpython.py
+++ b/Tools/gdb/libpython.py
@@ -905,7 +905,11 @@ class PyFrameObjectPtr(PyObjectPtr):
if self.is_optimized_out():
return '(frame information optimized out)'
filename = self.filename()
- with open(os_fsencode(filename), 'r') as f:
+ try:
+ f = open(os_fsencode(filename), 'r')
+ except IOError:
+ return None
+ with f:
all_lines = f.readlines()
# Convert from 1-based current_line_num to 0-based list offset:
return all_lines[self.current_line_num()-1]
@@ -1430,7 +1434,9 @@ class Frame(object):
if pyop:
line = pyop.get_truncated_repr(MAX_OUTPUT_LEN)
write_unicode(sys.stdout, '#%i %s\n' % (self.get_index(), line))
- sys.stdout.write(pyop.current_line())
+ line = pyop.current_line()
+ if line is not None:
+ sys.stdout.write(line)
else:
sys.stdout.write('#%i (unable to read python frame information)\n' % self.get_index())
else:
@@ -1441,7 +1447,9 @@ class Frame(object):
pyop = self.get_pyop()
if pyop:
pyop.print_traceback()
- sys.stdout.write(' %s\n' % pyop.current_line().strip())
+ line = pyop.current_line()
+ if line is not None:
+ sys.stdout.write(' %s\n' % line.strip())
else:
sys.stdout.write(' (unable to read python frame information)\n')
else:
@@ -1501,7 +1509,13 @@ class PyList(gdb.Command):
if start<1:
start = 1
- with open(os_fsencode(filename), 'r') as f:
+ try:
+ f = open(os_fsencode(filename), 'r')
+ except IOError as err:
+ sys.stdout.write('Unable to open %s: %s\n'
+ % (filename, err))
+ return
+ with f:
all_lines = f.readlines()
# start and end are 1-based, all_lines is 0-based;
# so [start-1:end] as a python slice gives us [start, end] as a