# Non-strict algorithm is to find as much of the target directory
# as we can and join the rest.
- tail = ''
+ tail = path[:0]
while path:
try:
path = _getfinalpathname(path)
import ntpath
import os
+import string
import sys
import unittest
import warnings
self.assertPathEqual(ntpath.realpath(os.fsencode(ABSTFN + "1")),
os.fsencode(ABSTFN))
+ # gh-88013: call ntpath.realpath with binary drive name may raise a
+ # TypeError. The drive should not exist to reproduce the bug.
+ for c in string.ascii_uppercase:
+ d = f"{c}:\\"
+ if not ntpath.exists(d):
+ break
+ else:
+ raise OSError("No free drive letters available")
+ self.assertEqual(ntpath.realpath(d), d)
+
@os_helper.skip_unless_symlink
@unittest.skipUnless(HAVE_GETFINALPATHNAME, 'need _getfinalpathname')
def test_realpath_strict(self):