mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
[3.11] GH-88013: Fix TypeError raised by ntpath.realpath in some cases (GH-102813, GH-103343)
(cherry picked from commit 4dc339b4d6
)
Co-authored-by: AN Long <aisk@users.noreply.github.com>
Co-authored-by: Barney Gale <barney.gale@gmail.com>
This commit is contained in:
parent
b8d1623f73
commit
70bc8c936d
3 changed files with 14 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
|||
import ntpath
|
||||
import os
|
||||
import string
|
||||
import sys
|
||||
import unittest
|
||||
import warnings
|
||||
|
@ -321,6 +322,16 @@ class TestNtpath(NtpathTestCase):
|
|||
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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue