bpo-43607: Fix urllib handling of Windows paths with \\?\ prefix (GH-25539)

This commit is contained in:
Steve Dower 2021-04-23 18:02:47 +01:00 committed by GitHub
parent 7d37b86ad4
commit 3513d55a61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 1 deletions

View file

@ -1526,6 +1526,24 @@ class Pathname_Tests(unittest.TestCase):
"url2pathname() failed; %s != %s" %
(expect, result))
@unittest.skipUnless(sys.platform == 'win32',
'test specific to the nturl2path functions.')
def test_prefixes(self):
# Test special prefixes are correctly handled in pathname2url()
given = '\\\\?\\C:\\dir'
expect = '///C:/dir'
result = urllib.request.pathname2url(given)
self.assertEqual(expect, result,
"pathname2url() failed; %s != %s" %
(expect, result))
given = '\\\\?\\unc\\server\\share\\dir'
expect = '/server/share/dir'
result = urllib.request.pathname2url(given)
self.assertEqual(expect, result,
"pathname2url() failed; %s != %s" %
(expect, result))
@unittest.skipUnless(sys.platform == 'win32',
'test specific to the urllib.url2path function.')
def test_ntpath(self):