From 1ff26c0ca289f48119b07f58876303686dddac61 Mon Sep 17 00:00:00 2001 From: barneygale Date: Tue, 29 Oct 2024 23:32:59 +0000 Subject: [PATCH] Windows test fixes #5 --- Lib/test/test_urllib.py | 4 ++-- Lib/urllib/request.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py index 16aa1751b09203..5527374020b80e 100644 --- a/Lib/test/test_urllib.py +++ b/Lib/test/test_urllib.py @@ -1575,11 +1575,11 @@ def test_url2pathname_win(self): 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.assertEqual(fn("///\u00e8|/"), "\\\u00e8|\\") + self.assertEqual(fn("///\u00e8|/"), "u00e8:\\") # UNC paths self.assertEqual(fn('//server/path/to/file'), '\\\\server\\path\\to\\file') self.assertEqual(fn('////server/path/to/file'), '\\\\server\\path\\to\\file') - self.assertEqual(fn('/////server/path/to/file'), '\\\\\\server\\path\\to\\file') + self.assertEqual(fn('/////server/path/to/file'), '\\\\server\\path\\to\\file') # Localhost paths self.assertEqual(fn('//localhost/C:/path/to/file'), 'C:\\path\\to\\file') self.assertEqual(fn('//localhost/C|/path/to/file'), 'C:\\path\\to\\file') diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py index cc01034171a61f..28839a40b7833d 100644 --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -1654,7 +1654,7 @@ def url2pathname(url): """Convert the percent-encoded URL *url* to a local pathname.""" scheme, authority, path = urlsplit(url, scheme='file')[:3] if scheme != 'file': - raise URLError(f'URI does not use "file" scheme: {url!r}') + raise URLError(f'URL {url!r} uses non-`file` scheme {scheme!r}') if os.name == 'nt': path = unquote(path) if authority and authority != 'localhost': @@ -1673,7 +1673,7 @@ def url2pathname(url): path = path.replace('/', '\\') else: if not _is_local_host(authority): - raise URLError(f'file URI not on local host: {url!r}') + raise URLError(f'URL {url!r} uses non-local authority {authority!r}') path = unquote(path) return path