New submission from Vlad Shcherbina:
When directory exists with a name chosen for new temporary file, OSError with
EACCESS errno is thrown on windows, while attempts to chose another name only
happen on EEXIST errors.
To reproduce, run
--------------- 8< -----------------
import sys
import tempfile
import os
print sys.platform
print sys.version
# Mock random names to ensure collision.
tempfile._RandomNameSequence = lambda: iter(['a', 'a', 'b'])
d = tempfile.mkdtemp()
print d
try:
print tempfile.NamedTemporaryFile().name
finally:
os.rmdir(d)
--------------- >8 -----------------
Expected result:
win32
2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)]
...\tmpa
...\tmpb
Actual result:
win32
2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)]
c:\users\shcher~1\appdata\local\temp\tmpa
Traceback (most recent call last):
File "hz.py", line 13, in <module>
print tempfile.NamedTemporaryFile().name
File "C:\python_27_amd64\files\lib\tempfile.py", line 454, in
NamedTemporaryFile
(fd, name) = _mkstemp_inner(dir, prefix, suffix, flags)
File "C:\python_27_amd64\files\lib\tempfile.py", line 235, in _mkstemp_inner
fd = _os.open(file, flags, 0600)
OSError: [Errno 13] Permission denied:
'c:\\users\\shcher~1\\appdata\\local\\temp\\tmpa'
----------
components: Library (Lib), Windows
messages: 196269
nosy: Vlad.Shcherbina
priority: normal
severity: normal
status: open
title: Failure to try another name for tempfile when directory with chosen name
exists on windows
type: behavior
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue18849>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com