diff -r 8b1418e5dcc8 Lib/idlelib/EditorWindow.py --- a/Lib/idlelib/EditorWindow.py Wed Oct 28 03:14:56 2015 -0400 +++ b/Lib/idlelib/EditorWindow.py Thu Oct 29 04:53:00 2015 -0400 @@ -146,7 +146,7 @@ self.tkinter_vars = {} # keys: Tkinter event names # values: Tkinter variable instances self.top.instance_dict = {} - self.recent_files_path = os.path.join(idleConf.GetUserCfgDir(), + self.recent_files_path = os.path.join(idleConf.userdir, 'recent-files.lst') self.text_frame = text_frame = Frame(top) self.vbar = vbar = Scrollbar(text_frame, name='vbar') diff -r 8b1418e5dcc8 Lib/idlelib/PyShell.py --- a/Lib/idlelib/PyShell.py Wed Oct 28 03:14:56 2015 -0400 +++ b/Lib/idlelib/PyShell.py Thu Oct 29 04:53:00 2015 -0400 @@ -125,7 +125,7 @@ self.text.bind("<>", self.clear_breakpoint_here) self.text.bind("<>", self.flist.open_shell) - self.breakpointPath = os.path.join(idleConf.GetUserCfgDir(), + self.breakpointPath = os.path.join(idleConf.userdir, 'breakpoints.lst') # whenever a file is changed, restore breakpoints def filename_changed_hook(old_hook=self.io.filename_change_hook, diff -r 8b1418e5dcc8 Lib/idlelib/configHandler.py --- a/Lib/idlelib/configHandler.py Wed Oct 28 03:14:56 2015 -0400 +++ b/Lib/idlelib/configHandler.py Thu Oct 29 04:53:00 2015 -0400 @@ -20,11 +20,28 @@ import os import sys +import shutil # shutil, tempfile, weakref for TempDir +import tempfile +import weakref from configparser import ConfigParser from tkinter import TkVersion from tkinter.font import Font, nametofont +class TempDir(): + """Reduce tempfile.TemporaryDirectory to exit cleanup. + + t.TK is not in 2.7, don't need args, context manager, or warning. + A reference must be kept to the instance, not just its name. + """ + def __init__(self): + self.name = tempfile.mkdtemp() + self._finalizer = weakref.finalize( + self, self._cleanup, self.name) + @classmethod + def _cleanup(cls, name): + shutil.rmtree(name) + class InvalidConfigType(Exception): pass class InvalidConfigSet(Exception): pass class InvalidFgBg(Exception): pass @@ -167,7 +184,7 @@ idleDir=os.path.dirname(__file__) else: # we were exec'ed (for testing only) idleDir=os.path.abspath(sys.path[0]) - userDir=self.GetUserCfgDir() + userDir = self.userdir = self.GetUserCfgDir() defCfgFiles = {} usrCfgFiles = {} @@ -205,11 +222,18 @@ try: os.mkdir(userDir) except OSError: - warn = ('\n Warning: unable to create user config directory\n' + - userDir + '\n Check path and permissions.\n Exiting!\n') - print(warn, file=sys.stderr) - raise SystemExit - # TODO continue without userDIr instead of exit + baddir = userDir + t = self._temp_userdir = TempDir() + userDir = os.path.join(t.name, cfgDir) + warn = ("\n Warning: cannot create user config directory\n" + "%s\Trying temporary directory\n%s\n" + "This will be deleted when IDLE exits." + % (baddir, userDir)) + try: + print(warn, file=sys.stderr) + except OSError: + pass + os.mkdir(userDir) return userDir def GetOption(self, configType, section, option, default=None, type=None,