mirror of
https://github.com/python/cpython.git
synced 2025-08-29 05:05:03 +00:00
Fix #11939. Set st_dev attribute on Windows to simplify os.path.samefile.
By setting the st_dev attribute, we can then remove some Windows-specific code and move os.path.samefile/sameopenfile/samestat to Lib/genericpath.py so all platforms share the same implementation.
This commit is contained in:
parent
2bf61abe02
commit
490b32a397
7 changed files with 104 additions and 139 deletions
|
@ -652,23 +652,6 @@ except (AttributeError, ImportError):
|
|||
def _getfinalpathname(f):
|
||||
return normcase(abspath(f))
|
||||
|
||||
def samefile(f1, f2):
|
||||
"Test whether two pathnames reference the same actual file"
|
||||
return _getfinalpathname(f1) == _getfinalpathname(f2)
|
||||
|
||||
|
||||
try:
|
||||
from nt import _getfileinformation
|
||||
except ImportError:
|
||||
# On other operating systems, just return the fd and see that
|
||||
# it compares equal in sameopenfile.
|
||||
def _getfileinformation(fd):
|
||||
return fd
|
||||
|
||||
def sameopenfile(f1, f2):
|
||||
"""Test whether two file objects reference the same file"""
|
||||
return _getfileinformation(f1) == _getfileinformation(f2)
|
||||
|
||||
|
||||
try:
|
||||
# The genericpath.isdir implementation uses os.stat and checks the mode
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue