Skip to content

Commit d03b775

Browse files
timgrahamzooba
authored andcommitted
bpo-31047: Fix ntpath.abspath to trim ending separator (GH-10082)
Regression in b0bf51b.
1 parent e25d5fc commit d03b775

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

Lib/ntpath.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ def _abspath_fallback(path):
523523
def abspath(path):
524524
"""Return the absolute version of a path."""
525525
try:
526-
return _getfullpathname(path)
526+
return normpath(_getfullpathname(path))
527527
except (OSError, ValueError):
528528
return _abspath_fallback(path)
529529

Lib/test/test_ntpath.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,8 @@ def test_abspath(self):
284284
tester('ntpath.abspath("")', cwd_dir)
285285
tester('ntpath.abspath(" ")', cwd_dir + "\\ ")
286286
tester('ntpath.abspath("?")', cwd_dir + "\\?")
287+
drive, _ = ntpath.splitdrive(cwd_dir)
288+
tester('ntpath.abspath("/abc/")', drive + "\\abc")
287289

288290
def test_relpath(self):
289291
tester('ntpath.relpath("a")', 'a')
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix ``ntpath.abspath`` regression where it didn't remove a trailing
2+
separator on Windows. Patch by Tim Graham.

0 commit comments

Comments
 (0)