Message359176
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. |
|
Date |
User |
Action |
Args |
2020-01-01 22:54:50 | db3l | set | recipients:
+ db3l, orsenthil, scoder, r.david.murray, Sohaib Ahmad, gson, pablogsal |
2020-01-01 22:54:50 | db3l | set | messageid: <1577919290.32.0.559737473254.issue27973@roundup.psfhosted.org> |
2020-01-01 22:54:50 | db3l | link | issue27973 messages |
2020-01-01 22:54:49 | db3l | create | |
|