Tim Golden added the comment:
Had a to-and-fro on IRC with RDM who highlighted that an inconsistency between
os.listdir and os.path.exists (the case here) is, at least, undesirable. As it
stands, our os.exists on os.stat mechanism will fail because any attempt to get
any kind of handle via
New submission from Jeremy Kloth:
os.stat fails when called on a file that is pending delete but is still in the
directory listing.
This in turn causes os.path.exists to return the wrong result.
Attached is a test case demonstrating this broken behavior.
--
components: Library (Lib),
Changes by Jeremy Kloth jeremy.kloth+python-trac...@gmail.com:
--
nosy: +brian.curtin, loewis, pitrou, tim.golden -jkloth
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15556
___
Changes by Jeremy Kloth jeremy.kloth+python-trac...@gmail.com:
--
nosy: +jkloth
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15556
___
___
Antoine Pitrou added the comment:
How does it fail? Please paste the precise exception.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15556
___
Jeremy Kloth added the comment:
Traceback (most recent call last):
File stat-bug.py, line 12, in module
print('stat', os.stat(pathname))
PermissionError: [Error 5] Access is denied: '\\Users\\Jeremy\\test.tmp'
--
___
Python tracker
Martin v. Löwis added the comment:
Why do you think the behavior is broken? It looks right to me - it's not
possible to get file information for a file that is scheduled for deletion.
ISTM that rather os.path.exists has non-intuitive behavior; it shouldn't infer
from the PermissionError that
Jeremy Kloth added the comment:
Why do you think the behavior is broken? It looks right to me - it's not
possible to get file information for a file that is scheduled for deletion.
However you can when using MSVCRT's stat() function or even
FindFirstFile directly.
--
nosy:
Changes by Chris Jerdonek chris.jerdo...@gmail.com:
--
nosy: +cjerdonek
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15556
___
___