diff --git a/Lib/ntpath.py b/Lib/ntpath.py index 0e6de2829f3..11bb297e16b 100644 --- a/Lib/ntpath.py +++ b/Lib/ntpath.py @@ -523,7 +523,7 @@ else: # use native Windows method on Windows def abspath(path): """Return the absolute version of a path.""" try: - return _getfullpathname(path) + return normpath(_getfullpathname(path)) except (OSError, ValueError): return _abspath_fallback(path) diff --git a/Lib/test/test_ntpath.py b/Lib/test/test_ntpath.py index f37a9945ffd..223e50f12c6 100644 --- a/Lib/test/test_ntpath.py +++ b/Lib/test/test_ntpath.py @@ -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') diff --git a/Misc/NEWS.d/next/Library/2018-10-25-09-37-03.bpo-31047.kBbX8r.rst b/Misc/NEWS.d/next/Library/2018-10-25-09-37-03.bpo-31047.kBbX8r.rst new file mode 100644 index 00000000000..1e47bf4174e --- /dev/null +++ b/Misc/NEWS.d/next/Library/2018-10-25-09-37-03.bpo-31047.kBbX8r.rst @@ -0,0 +1,2 @@ +Fix ``ntpath.abspath`` regression where it didn't remove a trailing +separator on Windows. Patch by Tim Graham.