]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Improve error handling when .idlerc can't be created (warn and exit)
authorKurt B. Kaiser <kbk@shore.net>
Wed, 19 Jan 2005 17:12:49 +0000 (17:12 +0000)
committerKurt B. Kaiser <kbk@shore.net>
Wed, 19 Jan 2005 17:12:49 +0000 (17:12 +0000)
Lib/idlelib/NEWS.txt
Lib/idlelib/configHandler.py

index 86a604066a9f1134c67224a50bafcc9b0e389526..248d3e8ef7b2c8cb5fc708eaca5cfafff56ed13a 100644 (file)
@@ -1,7 +1,9 @@
 What's New in IDLE 1.1.1?
 =======================
 
-*Release date: XX-DEC-2004*
+*Release date: XX-JAN-2005*
+
+- Improve error handling when .idlerc can't be created (warn and exit)
 
 - The GUI was hanging if the shell window was closed while a raw_input() 
   was pending.  Restored the quit() of the readline() mainloop().
index 370f3707def932703f9742a287a7d6894bca880c..d13f1e4ccf3d21f9a8f9a55d5961f8ac5168b4a6 100644 (file)
@@ -193,26 +193,28 @@ class IdleConf:
         """
         Creates (if required) and returns a filesystem directory for storing
         user config files.
+        
         """
-        cfgDir='.idlerc'
-        userDir=os.path.expanduser('~')
-        if userDir != '~': #'HOME' exists as a key in os.environ
+        cfgDir = '.idlerc'
+        userDir = os.path.expanduser('~')
+        if userDir != '~': # expanduser() found user home dir
             if not os.path.exists(userDir):
-                warn=('\n Warning: HOME environment variable points to\n '+
-                        userDir+'\n but the path does not exist.\n')
+                warn = ('\n Warning: os.path.expanduser("~") points to\n '+
+                        userDir+',\n but the path does not exist.\n')
                 sys.stderr.write(warn)
-                userDir='~'
-        if userDir=='~': #we still don't have a home directory
-            #traditionally idle has defaulted to os.getcwd(), is this adeqate?
-            userDir = os.getcwd() #hack for no real homedir
-        userDir=os.path.join(userDir,cfgDir)
+                userDir = '~'
+        if userDir == "~": # still no path to home!
+            # traditionally IDLE has defaulted to os.getcwd(), is this adequate?
+            userDir = os.getcwd()
+        userDir = os.path.join(userDir, cfgDir)
         if not os.path.exists(userDir):
-            try: #make the config dir if it doesn't exist yet
+            try:
                 os.mkdir(userDir)
-            except IOError:
-                warn=('\n Warning: unable to create user config directory\n '+
-                        userDir+'\n')
+            except (OSError, IOError):
+                warn = ('\n Warning: unable to create user config directory\n'+
+                        userDir+'\n Check path and permissions.\n Exiting!\n\n')
                 sys.stderr.write(warn)
+                raise SystemExit
         return userDir
 
     def GetOption(self, configType, section, option, default=None, type=None,