Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(20)

Unified Diff: Tools/gdb/libpython.py

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Python/_warnings.c ('k') | Tools/msi/msi.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Tools/gdb/libpython.py Tue Jul 26 09:37:46 2011 +0300
+++ b/Tools/gdb/libpython.py Mon Jul 25 09:47:18 2011 -0400
@@ -905,11 +905,7 @@
if self.is_optimized_out():
return '(frame information optimized out)'
filename = self.filename()
- try:
- f = open(os_fsencode(filename), 'r')
- except IOError:
- return None
- with f:
+ with open(os_fsencode(filename), 'r') as 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]
@@ -1434,9 +1430,7 @@
if pyop:
line = pyop.get_truncated_repr(MAX_OUTPUT_LEN)
write_unicode(sys.stdout, '#%i %s\n' % (self.get_index(), line))
- line = pyop.current_line()
- if line is not None:
- sys.stdout.write(line)
+ sys.stdout.write(pyop.current_line())
else:
sys.stdout.write('#%i (unable to read python frame information)\n' % self.get_index())
else:
@@ -1447,9 +1441,7 @@
pyop = self.get_pyop()
if pyop:
pyop.print_traceback()
- line = pyop.current_line()
- if line is not None:
- sys.stdout.write(' %s\n' % line.strip())
+ sys.stdout.write(' %s\n' % pyop.current_line().strip())
else:
sys.stdout.write(' (unable to read python frame information)\n')
else:
@@ -1509,13 +1501,7 @@
if start<1:
start = 1
- 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:
+ with open(os_fsencode(filename), 'r') as 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
« no previous file with comments | « Python/_warnings.c ('k') | Tools/msi/msi.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+