Fix #9790: Rework the imports necessary for ntpath.samefile and
ntpath.sameopenfile.
This commit is contained in:
parent
972412d168
commit
0dac808b3e
|
@ -641,24 +641,29 @@ def relpath(path, start=curdir):
|
||||||
|
|
||||||
|
|
||||||
# determine if two files are in fact the same file
|
# determine if two files are in fact the same file
|
||||||
|
try:
|
||||||
|
from nt import _getfinalpathname
|
||||||
|
except (NotImplementedError, ImportError):
|
||||||
|
# On Windows XP and earlier, two files are the same if their absolute
|
||||||
|
# pathnames are the same.
|
||||||
|
# Also, on other operating systems, fake this method with a
|
||||||
|
# Windows-XP approximation.
|
||||||
|
def _getfinalpathname(f):
|
||||||
|
return abspath(f)
|
||||||
|
|
||||||
def samefile(f1, f2):
|
def samefile(f1, f2):
|
||||||
"Test whether two pathnames reference the same actual file"
|
"Test whether two pathnames reference the same actual file"
|
||||||
try:
|
return _getfinalpathname(f1) == _getfinalpathname(f2)
|
||||||
from nt import _getfinalpathname
|
|
||||||
return _getfinalpathname(f1) == _getfinalpathname(f2)
|
|
||||||
except (NotImplementedError, ImportError):
|
try:
|
||||||
# On Windows XP and earlier, two files are the same if their
|
from nt import _getfileinformation
|
||||||
# absolute pathnames are the same.
|
except ImportError:
|
||||||
# Also, on other operating systems, fake this method with a
|
# On other operating systems, just return the fd and see that
|
||||||
# Windows-XP approximation.
|
# it compares equal in sameopenfile.
|
||||||
return abspath(f1) == abspath(f2)
|
def _getfileinformation(fd):
|
||||||
|
return fd
|
||||||
|
|
||||||
def sameopenfile(f1, f2):
|
def sameopenfile(f1, f2):
|
||||||
"""Test whether two file objects reference the same file"""
|
"""Test whether two file objects reference the same file"""
|
||||||
try:
|
return _getfileinformation(f1) == _getfileinformation(f2)
|
||||||
from nt import _getfileinformation
|
|
||||||
return _getfileinformation(f1) == _getfileinformation(f2)
|
|
||||||
except ImportError:
|
|
||||||
# On other operating systems, return True if the file descriptors
|
|
||||||
# are the same.
|
|
||||||
return f1 == f2
|
|
||||||
|
|
|
@ -68,6 +68,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #9790: Rework imports necessary for samefile and sameopenfile
|
||||||
|
in ntpath.
|
||||||
|
|
||||||
- Issue #9928: Properly initialize the types exported by the bz2 module.
|
- Issue #9928: Properly initialize the types exported by the bz2 module.
|
||||||
|
|
||||||
- Issue #1675951: Allow GzipFile to work with unseekable file objects.
|
- Issue #1675951: Allow GzipFile to work with unseekable file objects.
|
||||||
|
|
Loading…
Reference in New Issue