[3.7] bpo-31047: Fix ntpath.abspath to trim ending separator (GH-10082)
This commit is contained in:
parent
69a3f153a9
commit
a7ffb66395
|
@ -523,8 +523,8 @@ else: # use native Windows method on Windows
|
|||
def abspath(path):
|
||||
"""Return the absolute version of a path."""
|
||||
try:
|
||||
return _getfullpathname(path)
|
||||
except OSError:
|
||||
return normpath(_getfullpathname(path))
|
||||
except (OSError, ValueError):
|
||||
return _abspath_fallback(path)
|
||||
|
||||
# realpath is a no-op on systems without islink support
|
||||
|
|
|
@ -284,6 +284,8 @@ class TestNtpath(unittest.TestCase):
|
|||
tester('ntpath.abspath("")', cwd_dir)
|
||||
tester('ntpath.abspath(" ")', cwd_dir + "\\ ")
|
||||
tester('ntpath.abspath("?")', cwd_dir + "\\?")
|
||||
drive, _ = ntpath.splitdrive(cwd_dir)
|
||||
tester('ntpath.abspath("/abc/")', drive + "\\abc")
|
||||
|
||||
def test_relpath(self):
|
||||
tester('ntpath.relpath("a")', 'a')
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
Fix ``ntpath.abspath`` regression where it didn't remove a trailing
|
||||
separator on Windows. Patch by Tim Graham.
|
Loading…
Reference in New Issue