summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2003-07-22 02:50:01 (GMT)
committerTim Peters <tim.peters@gmail.com>2003-07-22 02:50:01 (GMT)
commit291f14e3d386714ea937489e1863bed7f818a970 (patch)
treef2b38ea809507e844dfded6ccde43e328470eaa7 /Lib
parentf1c9869ab016f041d2ae9e63b1e17983cc8a2826 (diff)
downloadcpython-291f14e3d386714ea937489e1863bed7f818a970.zip
cpython-291f14e3d386714ea937489e1863bed7f818a970.tar.gz
cpython-291f14e3d386714ea937489e1863bed7f818a970.tar.bz2
Windows fix: When PYTHONCASEOK is set, or for any other reason imports
are satisfied in a case-insensitive manner, the attempt to import (the non-existent) fcntl gets satisfied by FCNTL.py instead, and the tempfile module defines a Unix-specific _set_cloexec() function in that case. As a result, temp files can't be created then (blows up with an AttributeError trying to reference fcntl.fcntl). This just popped up in the spambayes project, where there is no apparent workaround (which is why I'm pushing this in now).
Diffstat (limited to 'Lib')
-rw-r--r--Lib/tempfile.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/Lib/tempfile.py b/Lib/tempfile.py
index 3682180..756d8c8 100644
--- a/Lib/tempfile.py
+++ b/Lib/tempfile.py
@@ -38,15 +38,21 @@ if _os.name == 'mac':
try:
import fcntl as _fcntl
+ # If PYTHONCASEOK is set on Windows, stinking FCNTL.py gets
+ # imported, and we don't get an ImportError then. Provoke
+ # an AttributeError instead in that case.
+ _fcntl.fcntl
+except (ImportError, AttributeError):
+ def _set_cloexec(fd):
+ pass
+else:
def _set_cloexec(fd):
flags = _fcntl.fcntl(fd, _fcntl.F_GETFD, 0)
if flags >= 0:
# flags read successfully, modify
flags |= _fcntl.FD_CLOEXEC
_fcntl.fcntl(fd, _fcntl.F_SETFD, flags)
-except (ImportError, AttributeError):
- def _set_cloexec(fd):
- pass
+
try:
import thread as _thread