This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Paul Doom
Recipients Billy McCulloch, Paul Doom, eryksun, georg.brandl, ncoghlan, paul.moore, python-dev, rupole, serhiy.storchaka, steve.dower, takluyver, tim.golden, zach.ware
Date 2016-12-05.09:49:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1480931360.01.0.64800983749.issue22107@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2016-12-05 09:49:20Paul Doomsetrecipients: + Paul Doom, georg.brandl, paul.moore, ncoghlan, rupole, tim.golden, python-dev, takluyver, zach.ware, serhiy.storchaka, eryksun, steve.dower, Billy McCulloch
2016-12-05 09:49:20Paul Doomsetmessageid: <1480931360.01.0.64800983749.issue22107@psf.upfronthosting.co.za>
2016-12-05 09:49:19Paul Doomlinkissue22107 messages
2016-12-05 09:49:19Paul Doomcreate