]> granicus.if.org Git - python/commitdiff
When getcwd() doesn't exist or raises an exception, don't fail but
authorGuido van Rossum <guido@python.org>
Thu, 9 Apr 1998 14:27:57 +0000 (14:27 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 9 Apr 1998 14:27:57 +0000 (14:27 +0000)
fall back to using os.curdir instead; if it is fine, don't use
os.curdir at all.

Lib/tempfile.py

index bd0ba606b33acc818b670f9ed6405edc5c58a372..6e87af1db7f942a12a553387112242f46cc74928 100644 (file)
@@ -20,7 +20,11 @@ def gettempdir():
     global tempdir
     if tempdir is not None:
         return tempdir
-    attempdirs = ['/usr/tmp', '/tmp', os.getcwd(), os.curdir]
+    try:
+        pwd = os.getcwd()
+    except (AttributeError, os.error):
+        pwd = os.curdir
+    attempdirs = ['/usr/tmp', '/tmp', pwd]
     if os.name == 'nt':
         attempdirs.insert(0, 'C:\\TEMP')
         attempdirs.insert(0, '\\TEMP')