mirror of
https://github.com/AdaCore/cpython.git
synced 2026-02-12 12:57:15 -08:00
Merge #12295 fix from 3.2
This commit is contained in:
@@ -62,14 +62,15 @@ def view_text(parent, title, text):
|
||||
|
||||
def view_file(parent, title, filename, encoding=None):
|
||||
try:
|
||||
textFile = open(filename, 'r', encoding=encoding)
|
||||
with open(filename, 'r', encoding=encoding) as file:
|
||||
contents = file.read()
|
||||
except IOError:
|
||||
import tkinter.messagebox as tkMessageBox
|
||||
tkMessageBox.showerror(title='File Load Error',
|
||||
message='Unable to load file %r .' % filename,
|
||||
parent=parent)
|
||||
else:
|
||||
return view_text(parent, title, textFile.read())
|
||||
return view_text(parent, title, contents)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user