From: Steve Dower Date: Thu, 25 Oct 2018 17:46:33 +0000 (-0400) Subject: bpo-31047: Fix ntpath.abspath to trim ending separator (GH-10082) X-Git-Tag: v3.6.8rc1~184 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4aa1fda7069642c21c1ee570c4ba44442a657e5e;p=thirdparty%2FPython%2Fcpython.git bpo-31047: Fix ntpath.abspath to trim ending separator (GH-10082) --- diff --git a/Lib/ntpath.py b/Lib/ntpath.py index 24113e701d11..1b23a15a945a 100644 --- a/Lib/ntpath.py +++ b/Lib/ntpath.py @@ -545,8 +545,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 diff --git a/Lib/test/test_ntpath.py b/Lib/test/test_ntpath.py index f93d902d32fa..bba1712ccef5 100644 --- a/Lib/test/test_ntpath.py +++ b/Lib/test/test_ntpath.py @@ -307,6 +307,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") except ImportError: self.skipTest('nt module not available') 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 000000000000..1e47bf4174e7 --- /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.