# HG changeset patch # User Ned Deily # Date 1295836808 28800 # Branch py3k # Node ID 024afca266bf1749a88afcc5d5f70bca3b94cddd # Parent 10e7cd80a6fa94c3fdf2cf30c34ac43611b1a2a7 Issue10974: IDLE 3.x can crash decoding recent file list. Force encoding of saved file paths to utf_8 and change encoding/decoding error handling to "replace". diff -r 10e7cd80a6fa -r 024afca266bf Lib/idlelib/EditorWindow.py --- Lib/idlelib/EditorWindow.py Sun Jan 23 22:33:36 2011 +0100 +++ Lib/idlelib/EditorWindow.py Sun Jan 23 18:40:08 2011 -0800 @@ -772,7 +772,8 @@ "Load and update the recent files list and menus" rf_list = [] if os.path.exists(self.recent_files_path): - rf_list_file = open(self.recent_files_path,'r') + rf_list_file = open(self.recent_files_path,'r', + encoding='utf_8', errors='replace') try: rf_list = rf_list_file.readlines() finally: @@ -790,7 +791,8 @@ rf_list = [path for path in rf_list if path not in bad_paths] ulchars = "1234567890ABCDEFGHIJK" rf_list = rf_list[0:len(ulchars)] - rf_file = open(self.recent_files_path, 'w') + rf_file = open(self.recent_files_path, 'w', + encoding='utf_8', errors='replace') try: rf_file.writelines(rf_list) finally: