Index: Lib/idlelib/IOBinding.py =================================================================== --- Lib/idlelib/IOBinding.py (Revision 68173) +++ Lib/idlelib/IOBinding.py (Arbeitskopie) @@ -7,7 +7,7 @@ import tkinter.messagebox as tkMessageBox import re from tkinter import * -from tkinter.simpledialog import SimpleDialog +from tkinter.simpledialog import askstring from idlelib.configHandler import idleConf @@ -281,8 +281,19 @@ # Finally, try the locale's encoding. This is deprecated; # the user should declare a non-ASCII encoding try: - chars = str(bytes, locale_encoding) - self.fileencoding = locale_encoding + # Wait for the editor window to appear + self.editwin.text.update() + enc = askstring( + "Specify file encoding", + "The file's encoding is invalid for Python 3.x.\n" + "IDLE will convert it to UTF-8.\n" + "What is the current encoding of the file?", + initialvalue = locale_encoding, + parent = self.editwin.text) + + if enc: + chars = str(bytes, enc) + self.fileencoding = None except UnicodeDecodeError: pass return chars # None on failure