[issue26111] On Windows, os.scandir will keep a handle on the directory until the iterator is exhausted

2021-02-25 Thread Steve Dower
Steve Dower added the comment: > FYI, in Windows 10, deleting files and directories now tries a POSIX delete Yeah, FWIW, I haven't been able to get clear guidance on what I can/cannot publicly announce we've done in this space. But since you've found it I guess I can say sorry that I

[issue26111] On Windows, os.scandir will keep a handle on the directory until the iterator is exhausted

2021-02-24 Thread Eryk Sun
Eryk Sun added the comment: Issue 25994 added support for the context-manager protocol and close() method in 3.6. So it's at least much easier to ensure that the handle gets closed. The documentation of scandir() links to WinAPI FindFirstFile and FindNextFile, which at least mentions the

[issue26111] On Windows, os.scandir will keep a handle on the directory until the iterator is exhausted

2016-01-14 Thread Eryk Sun
Eryk Sun added the comment: > That behavior on Windows is quite counterintuitive. It's counter-intuitive from a POSIX point of view, in which anonymous files are allowed. In contrast, Windows allows any existing reference to unset the delete disposition, so the name cannot be unlinked until

[issue26111] On Windows, os.scandir will keep a handle on the directory until the iterator is exhausted

2016-01-14 Thread Martin Panter
Martin Panter added the comment: Can you explain how it is different? The way I see it, both problems are about the scandir() iterator holding an open reference (file descriptor or handle) to a directory/folder, when the iterator was not exhausted, but the caller no longer needs it.

[issue26111] On Windows, os.scandir will keep a handle on the directory until the iterator is exhausted

2016-01-14 Thread Remy Roy
Remy Roy added the comment: >From my point of view, Issue 25994 is about the potential file >descriptor/handle leaks and this issue is about being unable to perform some >filesystem calls because of a hidden unclosed file descriptor/handle. I am not going to protest if you want to treat them

[issue26111] On Windows, os.scandir will keep a handle on the directory until the iterator is exhausted

2016-01-14 Thread Eryk Sun
Eryk Sun added the comment: If you own the only reference you can also delete the reference, which deallocates the iterator and closes the handle. Can you provide concrete examples where os.remove and os.chmod fail? At least in Windows 7 and 10 the directory handle is opened with the normal

[issue26111] On Windows, os.scandir will keep a handle on the directory until the iterator is exhausted

2016-01-14 Thread Ben Hoyt
Changes by Ben Hoyt : -- nosy: +benhoyt ___ Python tracker ___ ___ Python-bugs-list

[issue26111] On Windows, os.scandir will keep a handle on the directory until the iterator is exhausted

2016-01-14 Thread Remy Roy
New submission from Remy Roy: On Windows, os.scandir will keep a handle on the directory being scanned until the iterator is exhausted. This behavior can cause various problems if try to use some filesystem calls like os.chmod or os.remove on the directory while the handle is still being