Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling Path.exists() on non-existent drive raises WindowsError #47

Closed
assumptionsoup opened this issue Dec 14, 2018 · 5 comments
Closed

Comments

@assumptionsoup
Copy link

assumptionsoup commented Dec 14, 2018

Any idea why this is happening?

>>> import pathlib2 as pathlib
>>> pathlib.Path(r"E:\Whatever\blah.txt").exists()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "P:\common\rez\packages\pathlib2\2.3.2\pathlib2\__init__.py", line 1549, in exists
    self.stat()
  File "P:\common\rez\packages\pathlib2\2.3.2\pathlib2\__init__.py", line 1356, in stat
    return self._accessor.stat(self)
  File "P:\common\rez\packages\pathlib2\2.3.2\pathlib2\__init__.py", line 541, in wrapped
    return strfunc(str(pathobj), *args)
WindowsError: [Error 21] The device is not ready: 'E:\\Whatever\\blah.txt'
>>> import os
>>> os.path.exists(r"E:\Whatever\blah.txt")
False
>>> pathlib.Path(r"C:\whatever\blah.txt").exists()
False

I tested this with version 2.3.2 and the latest commit 87f9a0e

@assumptionsoup assumptionsoup changed the title Calling exists on non-existant drive raises WindowsError Calling Path.exists() on non-existant drive raises WindowsError Dec 14, 2018
@assumptionsoup assumptionsoup changed the title Calling Path.exists() on non-existant drive raises WindowsError Calling Path.exists() on non-existent drive raises WindowsError Dec 14, 2018
@mcmtroffaes
Copy link
Collaborator

No idea... I do note that standard python has precisely same implementation for the exists() function i.e. uses a stat call to determine whether a path exists. Can you try to see if

import pathlib
pathlib.Path(r"E:\Whatever\blah.txt").exists()

gives the same error? If so (and I expect it will), then you'll need to take this upstream.

@assumptionsoup
Copy link
Author

assumptionsoup commented Jan 7, 2019

Ah, you're right. This is an upstream issue. I'm seeing the same behavior with pathlib in python3.

@mcmtroffaes
Copy link
Collaborator

Ok. When it gets fixed there, the fix should land back here as well with the next upstream sync.

@assumptionsoup
Copy link
Author

Sounds good. I've gone ahead and created an issue upstream in the python tracker https://bugs.python.org/issue35692

mcmtroffaes added a commit that referenced this issue Mar 11, 2019
This includes a fix for issue #47.
@mcmtroffaes
Copy link
Collaborator

The fix is now in develop, and will be included with the next release. It should work now, if not, do let me know and I'll look into it. Thanks once more for engaging with upstream to get this addressed!

mrbean-bremen added a commit to mrbean-bremen/pyfakefs that referenced this issue Jun 30, 2019
mrbean-bremen added a commit to mrbean-bremen/pyfakefs that referenced this issue Jun 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants