diff -r 0ca9e0aa06df Lib/idlelib/IOBinding.py --- a/Lib/idlelib/IOBinding.py Fri Jul 25 00:55:23 2014 +0200 +++ b/Lib/idlelib/IOBinding.py Fri Jul 25 11:04:08 2014 +0800 @@ -233,8 +233,34 @@ chars = self.eol_re.sub(r"\n", chars) self.text.delete("1.0", "end") self.set_filename(None) - self.text.insert("1.0", chars) self.reset_undo() + + try: + self.text.insert("1.0", chars) + except: + # check non-bmp character + line_count = 1 + position_count = 0 + for char in chars: + if char == '\n': + line_count += 1 + position_count = 0 + elif ord(char) > 0xFFFF: + nonbmp_msg = \ + ("IDLE can't display non-BMP characters " + "(codepoint above 0xFFFF).\n" + "A non-BMP character (codepoint 0x%X) " + "found at line %d, position %d of file %s.\n\n" + "Please open this file with another editor.") + tkMessageBox.showerror("non-BMP character", + nonbmp_msg % + (ord(char), line_count, + position_count, filename), + parent=self.text) + return False + position_count += 1 + raise + self.set_filename(filename) if converted: # We need to save the conversion results first