[Python-checkins] python/dist/src/Lib tempfile.py,1.55,1.56

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
Mon, 21 Jul 2003 19:50:03 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1:/tmp/cvs-serv30780/Lib

Modified Files:
	tempfile.py 
Log Message:
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).


Index: tempfile.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/tempfile.py,v
retrieving revision 1.55
retrieving revision 1.56
diff -C2 -d -r1.55 -r1.56
*** tempfile.py	21 Mar 2003 12:55:10 -0000	1.55
--- tempfile.py	22 Jul 2003 02:50:01 -0000	1.56
***************
*** 39,42 ****
--- 39,50 ----
  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)
***************
*** 45,51 ****
              flags |= _fcntl.FD_CLOEXEC
              _fcntl.fcntl(fd, _fcntl.F_SETFD, flags)
! except (ImportError, AttributeError):
!     def _set_cloexec(fd):
!         pass
  
  try:
--- 53,57 ----
              flags |= _fcntl.FD_CLOEXEC
              _fcntl.fcntl(fd, _fcntl.F_SETFD, flags)
! 
  
  try: