the path component of a URL. This does not produce a complete URL. The return
value will already be quoted using the :func:`~urllib.parse.quote` function.
+ .. versionchanged:: 3.14
+ Windows drive letters are no longer converted to uppercase.
+
.. versionchanged:: 3.14
On Windows, ``:`` characters not following a drive letter are quoted. In
previous versions, :exc:`OSError` was raised if a colon character was
path. This does not accept a complete URL. This function uses
:func:`~urllib.parse.unquote` to decode *path*.
+ .. versionchanged:: 3.14
+ Windows drive letters are no longer converted to uppercase.
+
+
.. function:: getproxies()
This helper function returns a dictionary of scheme to proxy server URL
if len(comp) != 2 or comp[0][-1] not in string.ascii_letters:
error = 'Bad URL: ' + url
raise OSError(error)
- drive = comp[0][-1].upper()
+ drive = comp[0][-1]
tail = urllib.parse.unquote(comp[1].replace('/', '\\'))
return drive + ':' + tail
# DOS drive specified. Add three slashes to the start, producing
# an authority section with a zero-length authority, and a path
# section starting with a single slash.
- drive = f'///{drive.upper()}'
+ drive = f'///{drive}'
drive = urllib.parse.quote(drive, safe='/:')
tail = urllib.parse.quote(tail)
self.assertEqual(fn('\\\\?\\unc\\server\\share\\dir'), '//server/share/dir')
self.assertEqual(fn("C:"), '///C:')
self.assertEqual(fn("C:\\"), '///C:/')
+ self.assertEqual(fn('c:\\a\\b.c'), '///c:/a/b.c')
self.assertEqual(fn('C:\\a\\b.c'), '///C:/a/b.c')
self.assertEqual(fn('C:\\a\\b.c\\'), '///C:/a/b.c/')
self.assertEqual(fn('C:\\a\\\\b.c'), '///C:/a//b.c')
self.assertEqual(fn("///C/test/"), '\\C\\test\\')
self.assertEqual(fn("////C/test/"), '\\\\C\\test\\')
# DOS drive paths
+ 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:/path/to/file/'), 'C:\\path\\to\\file\\')
self.assertEqual(fn('C:/path/to//file'), 'C:\\path\\to\\\\file')
--- /dev/null
+:func:`urllib.request.pathname2url` and :func:`~urllib.request.url2pathname`
+no longer convert Windows drive letters to uppercase.