]> granicus.if.org Git - python/commitdiff
bpo-31047: Fix ntpath.abspath to trim ending separator (GH-10082)
authorTim Graham <timograham@gmail.com>
Thu, 25 Oct 2018 15:26:38 +0000 (11:26 -0400)
committerSteve Dower <steve.dower@microsoft.com>
Thu, 25 Oct 2018 15:26:37 +0000 (11:26 -0400)
Regression in b0bf51b32240369ccb736dc32ff82bb96f375402.

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 0e6de2829f3222eed596f1b1ce0f89d27d02a144..11bb297e16bf4e04b395fa95177c2091c79780df 100644 (file)
@@ -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)
 
index f37a9945ffdad60e9ee3625c91150db6f7bcfdf0..223e50f12c6d56839b51d0b9e3297942fca3832f 100644 (file)
@@ -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 (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.