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 db3l
Recipients Sohaib Ahmad, db3l, gson, orsenthil, pablogsal, r.david.murray, scoder
Date 2020-01-01.22:54:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1577919290.32.0.559737473254.issue27973@roundup.psfhosted.org>
In-reply-to
Content
The issue appears to be the temporary flag (O_TEMPORARY) that is used under Windows with delete on close temporary files.  That appears to prevent any separate access to the file by anyone else including obtaining another reference in the same process:

>>> temp = tempfile.NamedTemporaryFile()
>>> temp, temp.name
(<open file '<fdopen>', mode 'w+b' at 0x017958E8>, 'd:\\temp\\tmp44kugh')
>>> other = open(temp.name, 'r')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IOError: [Errno 13] Permission denied: 'd:\\temp\\tmp44kugh'

Changing the mode (PR 17774) of the temporary file has no effect.  Setting delete=False will work, but would defeat the point of using NamedTemporaryFile for the cleanup.

I don't see any way to have both auto-delete and the ability to write separately to a file under Windows with NamedTemporaryFile.

Perhaps instead use test.support.temp_dir for the overall test, and let it take care of the iteration temp files when cleaning up the entire directory?  Something like:

    with test_support.temp_dir() as td:
        for i in range(self.NUM_FTP_RETRIEVES):
            urllib.FancyURLopener().retrieve(self.FTP_TEST_FILE, os.path.join(td, str(i)))

That seems to work fine under Windows.
History
Date User Action Args
2020-01-01 22:54:50db3lsetrecipients: + db3l, orsenthil, scoder, r.david.murray, Sohaib Ahmad, gson, pablogsal
2020-01-01 22:54:50db3lsetmessageid: <1577919290.32.0.559737473254.issue27973@roundup.psfhosted.org>
2020-01-01 22:54:50db3llinkissue27973 messages
2020-01-01 22:54:49db3lcreate