File tree Expand file tree Collapse file tree 3 files changed +10
-1
lines changed Expand file tree Collapse file tree 3 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -670,7 +670,7 @@ def _getfinalpathname_nonstrict(path):
670670
671671 # Non-strict algorithm is to find as much of the target directory
672672 # as we can and join the rest.
673- tail = ''
673+ tail = path [: 0 ]
674674 while path :
675675 try :
676676 path = _getfinalpathname (path )
Original file line number Diff line number Diff line change 11import inspect
22import ntpath
33import os
4+ import string
45import sys
56import unittest
67import warnings
@@ -374,6 +375,12 @@ def test_realpath_basic(self):
374375 self .assertPathEqual (ntpath .realpath (os .fsencode (ABSTFN + "1" )),
375376 os .fsencode (ABSTFN ))
376377
378+ # gh-88013: call ntpath.realpath with binary drive name may raise a
379+ # TypeError. The drive should not exist to reproduce the bug.
380+ drives = {f"{ c } :\\ " for c in string .ascii_uppercase } - set (os .listdrives ())
381+ d = drives .pop ().encode ()
382+ self .assertEqual (ntpath .realpath (d ), d )
383+
377384 @os_helper .skip_unless_symlink
378385 @unittest .skipUnless (HAVE_GETFINALPATHNAME , 'need _getfinalpathname' )
379386 def test_realpath_strict (self ):
Original file line number Diff line number Diff line change 1+ Fixed a bug where :exc: `TypeError ` was raised when calling
2+ :func: `ntpath.realpath ` with a bytes parameter in some cases.
You can’t perform that action at this time.
0 commit comments