8000 bpo-38183: Test_idle ignores user config directory. by terryjreedy · Pull Request #16198 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-38183: Test_idle ignores use 8000 r config directory. #16198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Sep 16, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Don't read/write recent-files.lst when no userdir.
  • Loading branch information
terryjreedy committed Sep 16, 2019
commit d32b731ce5cac17a79387a3e47b720c0983b03aa
34 changes: 18 additions & 16 deletions Lib/idlelib/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def __init__(self, flist=None, filename=None, key=None, root=None):
self.tkinter_vars = {} # keys: Tkinter event names
# values: Tkinter variable instances
self.top.instance_dict = {}
self.recent_files_path = os.path.join(
self.recent_files_path = idleConf.userdir and os.path.join(
idleConf.userdir, 'recent-files.lst')

self.prompt_last_line = '' # Override in PyShell
Expand Down Expand Up @@ -924,9 +924,11 @@ def display_extra_help(helpfile=helpfile):

def update_recent_files_list(self, new_file=None):
"Load and update the recent files list and menus"
# TODO: move to iomenu.
rf_list = []
if os.path.exists(self.recent_files_path):
with open(self.recent_files_path, 'r',
file_path = self.recent_files_path
if file_path and os.path.exists(file_path):
with open(file_path, 'r',
encoding='utf_8', errors='replace') as rf_list_file:
rf_list = rf_list_file.readlines()
if new_file:
Expand All @@ -942,19 +944,19 @@ def update_recent_files_list(self, new_file=None):
rf_list = [path for path in rf_list if path not in bad_paths]
ulchars = "1234567890ABCDEFGHIJK"
rf_list = rf_list[0:len(ulchars)]
try:
with open(self.recent_files_path, 'w',
encoding='utf_8', errors='replace') as rf_file:
rf_file.writelines(rf_list)
except OSError as err:
if not getattr(self.root, "recentfilelist_error_displayed", False):
self.root.recentfilelist_error_displayed = True
tkMessageBox.showwarning(title='IDLE Warning',
message="Cannot update File menu Recent Files list. "
"Your operating system says:\n%s\n"
"Select OK and IDLE will continue without updating."
% self._filename_to_unicode(str(err)),
parent=self.text)
if file_path:
try:
with open(file_path, 'w',
encoding='utf_8', errors='replace') as rf_file:
rf_file.writelines(rf_list)
except OSError as err:
if not getattr(self.root, "recentfiles_message", False):
self.root.recentfiles_message = True
tkMessageBox.showwarning(title='IDLE Warning',
message="Cannot save Recent Files list to disk.\n"
f" {err}\n"
"Select OK to continue.",
parent=self.text)
# for each edit window instance, construct the recent files menu
for instance in self.top.instance_dict:
menu = instance.recent_files_menu
Expand Down
0