]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-31047: Fix ntpath.abspath to trim ending separator (GH-10082) 10104/head
authorSteve Dower <steve.dower@microsoft.com>
Thu, 25 Oct 2018 17:46:33 +0000 (13:46 -0400)
committerGitHub <noreply@github.com>
Thu, 25 Oct 2018 17:46:33 +0000 (13:46 -0400)
Lib/ntpath.py
Lib/test/test_ntpath.py
Misc/NEWS.d/next/Library/2018-10-25-09-37-03.bpo-31047.kBbX8r.rst [new file with mode: 0644]

index 24113e701d1152a72c370bcb9bb7961fdcf58cbf..1b23a15a945ac56291657401e9ffa8cef4ec3510 100644 (file)
@@ -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
index f93d902d32fa93330bbb331b8468ba427bccfdb7..bba1712ccef52ba5aeb9f14703fdcfa61d98ad0d 100644 (file)
@@ -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 (file)
index 0000000..1e47bf4
--- /dev/null
@@ -0,0 +1,2 @@
+Fix ``ntpath.abspath`` regression where it didn't remove a trailing
+separator on Windows. Patch by Tim Graham.