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
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.