##// END OF EJS Templates
Explicitly close file in get_encoding
Thomas Kluyver -
Show More
@@ -120,7 +120,7 b' def get_encoding(obj):'
120 120 # Print only text files, not extension binaries. Note that
121 121 # getsourcelines returns lineno with 1-offset and page() uses
122 122 # 0-offset, so we must adjust.
123 buffer = stdlib_io.open(ofile, 'rb') # Tweaked to use io.open for Python 2
123 with stdlib_io.open(ofile, 'rb') as buffer: # Tweaked to use io.open for Python 2
124 124 encoding, lines = openpy.detect_encoding(buffer.readline)
125 125 return encoding
126 126
General Comments 0
You need to be logged in to leave comments. Login now