summaryrefslogtreecommitdiffstats
path: root/Lib/tempfile.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1998-04-09 14:27:57 (GMT)
committerGuido van Rossum <guido@python.org>1998-04-09 14:27:57 (GMT)
commit29e5f5d81f19f40c47f2e63866d8474bc8602550 (patch)
treef56cb6702906d6539bd4b36dae873a5ca5537e68 /Lib/tempfile.py
parentc09e6b1c0ab8ea6e0f2cc77e87a602e909385c43 (diff)
downloadcpython-29e5f5d81f19f40c47f2e63866d8474bc8602550.zip
cpython-29e5f5d81f19f40c47f2e63866d8474bc8602550.tar.gz
cpython-29e5f5d81f19f40c47f2e63866d8474bc8602550.tar.bz2
When getcwd() doesn't exist or raises an exception, don't fail but
fall back to using os.curdir instead; if it is fine, don't use os.curdir at all.
Diffstat (limited to 'Lib/tempfile.py')
-rw-r--r--Lib/tempfile.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/tempfile.py b/Lib/tempfile.py
index bd0ba60..6e87af1 100644
--- a/Lib/tempfile.py
+++ b/Lib/tempfile.py
@@ -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')