-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
Implement stat.st_dev and os.path.samefile on windows #56148
Comments
Since 9cd1036455e7, os.stat() on Windows fills the st_ino member; |
I created/assigned bpo-10646 to myself for other samefile issues - I can cover this as well unless someone beats me to it. |
Here's a patch that fills st_dev, and while we're at it st_rdev (which is the same value). I've moved the implementation of samefile/sameopenfile/samestat from Lib/posixpath.py over to Lib/genericpath.py and then removed the implementation from Lib/ntpath.py, so those functions are now common. The same goes for tests - I've rearranged tests towards test_genericpath. I also removed _getfileinformation from Modules/posixmodule.c because it's no longer being used. |
What about macpath? I think test_macpath will fail. |
Why do you think that? I don't have a mac so I can't test it. |
Here is an updated patch addressing the sameopenfile that remained in Lib/ntpath.py, thanks to Sehriy's comment on the review. |
Hmm. test_macpath will now run the tests for samefile etc. macpath doesn't contain os.path.samefile. But in Modules/posixmodule.c I don't see any special cases for classic MacOS. Actually, I don't know how tests behave on classic MacOS. Please update the documentation (availability, versionchanged). |
On other hand, you should add "samefile", "sameopenfile" and "samestat" back to __all__ in posixpath and ntpath. __all__ is a list of exported names, not a list of defined names. |
Docs and the __all__ changes in V3 patch. |
New changeset 189b21f9bc0c by Brian Curtin in branch 'default': |
New changeset 82531b78b719 by Brian Curtin in branch 'default': |
Thanks for the reviews. |
New changeset 9e980454b85e by Brian Curtin in branch 'default': |
Try on Windows: >>> import os
>>> from os.path import *
>>> samestat(os.stat('.'), os.stat('.'))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'samestat' is not defined |
Separate issue. Fixed in bpo-16788. |
New changeset 3738d270c54a by Brian Curtin in branch 'default': |
But than st_dev used as long in _pystat_fromstructstat(). Perhaps you should |
New changeset 61bada808b34 by Brian Curtin in branch 'default': |
Now the code is wrong on non-Windows without PY_LONG_LONG and with signed st_dev. |
Backed out the changeset. If you have a solution, feel free to fix it. |
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: