You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2014-02-07.14:37:58.320>created_at=<Date2014-02-07.12:47:34.335>labels= ['invalid', 'type-bug', 'library', 'OS-windows']
title='os.path.exists() gives wrong answer for Windows special files'updated_at=<Date2014-02-07.17:28:55.890>user='https://github.com/ncoghlan'
In trying to figure out why my fix for bpo-20053 wasn't working on Windows, I eventually traced it back to the fact that "os.path.exists(os.devnull)" returns False on Windows, so pip isn't picking up my config file override in ensurepip, and reads the global default config file anyway.
However, if you do "if exist NUL (echo exists) ELSE (echo missing)" in cmd, it will print "exists", so this looks like a bug in our os.path.exists implementation.
That is currently implemented in genericpath and assumes that a file exists if-and-only-if os.stat(name) doesn't throw an exception.
It turns out this assumption isn't really correct on Windows - 'NUL' and 'CON' (and presumably other special files) can be opened, but trying to do os.stat() on them throws an exception.
As per bpo-1311, the exists returns True <-> stat will work equivalence is deliberate. We'll have to find a different way to resolve bpo-20053 on Windows.
Due to the special files on Windows, the only reliable cross-platform way to find out whether or not *open* will work on a given filename is to actually try it.
As per bpo-1311, the exists returns True <-> stat will work equivalence
is deliberate. We'll have to find a different way to resolve bpo-20053 on
Windows.
I was going t say we should note this design/impl. detail in the
os.path.exists() docs. However, it already is! :)
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: