##// END OF EJS Templates
Explicitly close file in get_encoding
Thomas Kluyver -
Show More
@@ -120,8 +120,8 b' def get_encoding(obj):'
120 # Print only text files, not extension binaries. Note that
120 # Print only text files, not extension binaries. Note that
121 # getsourcelines returns lineno with 1-offset and page() uses
121 # getsourcelines returns lineno with 1-offset and page() uses
122 # 0-offset, so we must adjust.
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 encoding, lines = openpy.detect_encoding(buffer.readline)
124 encoding, lines = openpy.detect_encoding(buffer.readline)
125 return encoding
125 return encoding
126
126
127 def getdoc(obj):
127 def getdoc(obj):
General Comments 0
You need to be logged in to leave comments. Login now