]> granicus.if.org Git - python/commitdiff
Windows fix: When PYTHONCASEOK is set, or for any other reason imports
authorTim Peters <tim.peters@gmail.com>
Tue, 22 Jul 2003 02:50:01 +0000 (02:50 +0000)
committerTim Peters <tim.peters@gmail.com>
Tue, 22 Jul 2003 02:50:01 +0000 (02:50 +0000)
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).

Lib/tempfile.py
Misc/NEWS

index 3682180d8e162708aa6ce46f5afa7e5e8756c037..756d8c87273e765cfe3a8b07ce63c69a6682c238 100644 (file)
@@ -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
index ce7aba2a44b19c997543f959a815c398f21ef371..7ba12183df28512a8044abebb248705bd2b11f14 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -39,6 +39,9 @@ C API
 Windows
 -------
 
+- The tempfile module could do insane imports on Windows if PYTHONCASEOK
+  was set, making temp file creation impossible.  Repaired.
+
 Mac
 ---