diff -r f6a3310d3cc9 Lib/idlelib/EditorWindow.py --- a/Lib/idlelib/EditorWindow.py Sat Aug 01 11:07:11 2015 -0700 +++ b/Lib/idlelib/EditorWindow.py Sun Aug 02 11:11:56 2015 +0530 @@ -351,18 +351,19 @@ def _filename_to_unicode(self, filename): """convert filename to unicode in order to display it in Tk""" - if isinstance(filename, str) or not filename: - return filename - else: + #byte on decoding gives astral /non-BMP chars + if isinstance(filename, bytes): try: - return filename.decode(self.filesystemencoding) + filename = filename.decode(self.filesystemencoding) except UnicodeDecodeError: # XXX try: - return filename.decode(self.encoding) + filename = filename.decode(self.encoding) except UnicodeDecodeError: # byte-to-byte conversion - return filename.decode('iso8859-1') + filename = filename.decode('iso8859-1') + #replace non-BMP char with diamond questionmark. + return re.sub('[\U00010000-\U0010FFFF]', '\ufffd', filename) def new_callback(self, event): dirname, basename = self.io.defaultfilename()