Paul Doom added the comment:

Can the _mkstemp_inner portion of Billy McCulloch's patch be applied? Due to a 
large default os.TMP_MAX value (2147483647 - seems to be the current value on 
Win 7/8.1/10 I have access to), the following will push  the CPU to 100% for a 
very long time when run under a non-elevated shell:

--
import tempfile
tempfile.TemporaryFile(dir='C:\Windows')
... wait ...
--

In _mkstemp_inner() we should be testing for the filename, not parent directory 
here:

        except PermissionError:
            # This exception is thrown when a directory with the chosen name
            # already exists on windows.
            if (_os.name == 'nt' and _os.path.isdir(dir) and
                _os.access(dir, _os.W_OK)):
                continue

Changing the _os.path.isdir(dir) call to _os.path.isdir(filename) is all that 
is needed to prevent the death loop and function correctly in cases where 
Windows os.access(dir, _os.W_OK) claims we have write access when we do not.

----------
nosy: +Paul Doom
type: behavior -> resource usage

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22107>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to