diff options
author | Barney Gale <barney.gale@gmail.com> | 2025-03-18 23:37:12 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-18 23:37:12 +0000 |
commit | d783d7b51d31db568de6b3438f4e805acff663da (patch) | |
tree | 67d3396e504207904878b2baefd4513aa3db2f57 /Lib/test/test_urllib.py | |
parent | 01b5abbc53b2a9ee8d85e0518c98efce27dbd061 (diff) | |
download | cpython-d783d7b51d31db568de6b3438f4e805acff663da.tar.gz cpython-d783d7b51d31db568de6b3438f4e805acff663da.zip |
GH-126367: `url2pathname()`: handle NTFS alternate data streams (#131428)
Adjust `url2pathname()` to decode embedded colon characters in Windows
URIs, rather than bailing out with an `OSError`.
Diffstat (limited to 'Lib/test/test_urllib.py')
-rw-r--r-- | Lib/test/test_urllib.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py index 4842428d6fd..ed23215c4d0 100644 --- a/Lib/test/test_urllib.py +++ b/Lib/test/test_urllib.py @@ -1484,6 +1484,7 @@ class Pathname_Tests(unittest.TestCase): 'test specific to Windows pathnames.') def test_url2pathname_win(self): fn = urllib.request.url2pathname + self.assertEqual(fn('/'), '\\') self.assertEqual(fn('/C:/'), 'C:\\') self.assertEqual(fn("///C|"), 'C:') self.assertEqual(fn("///C:"), 'C:') @@ -1502,8 +1503,10 @@ class Pathname_Tests(unittest.TestCase): self.assertEqual(fn('/C|/path/to/file'), 'C:\\path\\to\\file') self.assertEqual(fn('///C|/path/to/file'), 'C:\\path\\to\\file') self.assertEqual(fn("///C|/foo/bar/spam.foo"), 'C:\\foo\\bar\\spam.foo') - # Non-ASCII drive letter - self.assertRaises(IOError, fn, "///\u00e8|/") + # Colons in URI + self.assertEqual(fn('///\u00e8|/'), '\u00e8:\\') + self.assertEqual(fn('//host/share/spam.txt:eggs'), '\\\\host\\share\\spam.txt:eggs') + self.assertEqual(fn('///c:/spam.txt:eggs'), 'c:\\spam.txt:eggs') # UNC paths self.assertEqual(fn('//server/path/to/file'), '\\\\server\\path\\to\\file') self.assertEqual(fn('////server/path/to/file'), '\\\\server\\path\\to\\file') |