[Python-bugs-list] [ python-Bugs-591104 ] os.tmpfile() can fail on win32
noreply@sourceforge.net
noreply@sourceforge.net
Fri, 09 Aug 2002 23:21:10 -0700
Bugs item #591104, was opened at 2002-08-05 09:23
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=591104&group_id=5470
Category: Windows
Group: Python 2.2.1
Status: Open
Resolution: None
Priority: 5
Submitted By: Joseph Barillari (jdbarillari)
Assigned to: Mark Hammond (mhammond)
Summary: os.tmpfile() can fail on win32
Initial Comment:
I've discovered what appears to be a bug in Python 2.2.1
on Win32. I'm
using the 2.2.1 build that I downloaded from python.org.
I'm running
Windows 2000.
If os.tmpfile() is exceuted when the CWD is a UNC path,
the base of
which is not writeable by the current user, tmpfile will
fail. tempfile.TemporaryFile will work, so I suspect this is
a bug in os.tmpfile().
For example:
C:\>pwd
/cygdrive/c #I use cygwin
C:\>bash # I have to use bash; the DOS shell doesn't
support UNC paths
bash: .bashrc: No such file or directory
bash-2.05a$ cd //bopp/jbarilla
bash-2.05a$ pwd
//bopp/jbarilla
bash-2.05a$ python
Python 2.2.1 (#34, Apr 9 2002, 19:34:33) [MSC 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more
information.
>>> import os; os.tmpfile()
<open file '<tmpfile>', mode 'w+' at 0x007762C0> # It
works.
>>> ^Z
If I chmod 555 //bopp/jbarilla (from unix via NFS;
incidentally,
"chmod 555 ." from cygwin is ineffectual), then tmpfile
fails:
bash-2.05a$ pwd
//bopp/jbarilla
bash-2.05a$ python
Python 2.2.1 (#34, Apr 9 2002, 19:34:33) [MSC 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more
information.
>>> import os; os.tmpfile()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
OSError: [Errno 13] Permission denied # Oops.
# However, tempfile.TemporaryFile works:
>>> import tempfile; tempfile.TemporaryFile()
<open file 'c:\DOCUME~1\jbarilla\LOCALS~1
\Temp\~1880-0', mode 'w+b' at 0x00779B00>
--Joe
----------------------------------------------------------------------
Comment By: Jonathan Simms (slyphon)
Date: 2002-08-10 01:21
Message:
Logged In: YES
user_id=404786
Hi, I'm a bit new here, but I'd like to help...
This like a cygwin issue. I've been using cygwin as a
development environment for about a year, and nothing
has driven me more crazy than the consistent problems
converting between unc and win32 paths. There's the
cygpath utility that you can put to use, it'll convert
posix to win32 paths and vice-versa. Also, if you want
to use chmod and unix-style permissions with cygwin,
you need to make sure that the $CYGWIN variable has
been set to include 'ntsec'.
related to the cygwin environment variable:
http://cygwin.com/cygwin-ug-net/using-cygwinenv.html
...This advice comes with no warranty, and I apologise
if I'm mistakenly off-the-mark...
Cheers
--Jonathan
----------------------------------------------------------------------
Comment By: Joseph Barillari (jdbarillari)
Date: 2002-08-06 09:40
Message:
Logged In: YES
user_id=589825
\quote{BTW, do you really think this has something to do
with UNC
paths? From what you said it seems to be a matter of
having sufficient permission to scribble in the current
directory.}
Oops. You're right:
Z:\>touch a
touch: creating `a': Permission denied
Z:\>python
Python 2.2.1 (#34, Apr 9 2002, 19:34:33) [MSC 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more
information.
>>> import os; os.tmpfile()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
OSError: [Errno 13] Permission denied
>>>
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2002-08-05 22:19
Message:
Logged In: YES
user_id=31435
Assigned to Mark in case he has another idea, but I think
you're out of luck. os.tmpfile() does nothing except call
Microsoft's tmpfile() function, and that doesn't allow
specifying a directory. If you don't have permission to
create a file in the current directory, you lose, and Python's
behavior here will change when Microsoft's does.
tempfile.TemporaryFile() "simulates" a temp file via other
means, and can control which directory it uses.
BTW, do you really think this has something to do with UNC
paths? From what you said it seems to be a matter of
having sufficient permission to scribble in the current
directory.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=591104&group_id=5470