diff options
author | Terry Jan Reedy <tjreedy@udel.edu> | 2016-06-22 08:54:18 (GMT) |
---|---|---|
committer | Terry Jan Reedy <tjreedy@udel.edu> | 2016-06-22 08:54:18 (GMT) |
commit | 82c4615be02a4b6f46c7db6cb91bd490093fae2c (patch) | |
tree | cc2c32caf19cc2b2155d467bc53afe9522afa016 | |
parent | df1d34c1b4f1a0d38a865cf7cbfdce38edf933a4 (diff) | |
download | cpython-82c4615be02a4b6f46c7db6cb91bd490093fae2c.zip cpython-82c4615be02a4b6f46c7db6cb91bd490093fae2c.tar.gz cpython-82c4615be02a4b6f46c7db6cb91bd490093fae2c.tar.bz2 |
Issue #27365: add chunk
-rw-r--r-- | Lib/idlelib/textView.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/Lib/idlelib/textView.py b/Lib/idlelib/textView.py index 9dc8357..7664524 100644 --- a/Lib/idlelib/textView.py +++ b/Lib/idlelib/textView.py @@ -4,7 +4,7 @@ from tkinter import * from tkinter.ttk import Scrollbar -import tkinter.messagebox as tkMessageBox +from tkinter.messagebox import showerror class TextViewer(Toplevel): """A simple text viewer dialog for IDLE @@ -73,10 +73,14 @@ def view_file(parent, title, filename, encoding=None, modal=True): try: with open(filename, 'r', encoding=encoding) as file: contents = file.read() - except IOError: - tkMessageBox.showerror(title='File Load Error', - message='Unable to load file %r .' % filename, - parent=parent) + except OSError: + showerror(title='File Load Error', + message='Unable to load file %r .' % filename, + parent=parent) + except UnicodeDecodeError as err: + showerror(title='Unicode Decode Error', + message=str(err), + parent=parent) else: return view_text(parent, title, contents, modal) |