diff options
author | Barney Gale <barney.gale@gmail.com> | 2024-11-25 19:59:20 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-25 19:59:20 (GMT) |
commit | 5bb059fe606983814a445e4dcf9e96fd7cb4951a (patch) | |
tree | 676161387dee7f7b757b947199db07f8b29da54f /Doc/library | |
parent | a2ee89968299fc4f0da4b5a4165025b941213ba5 (diff) | |
download | cpython-5bb059fe606983814a445e4dcf9e96fd7cb4951a.zip cpython-5bb059fe606983814a445e4dcf9e96fd7cb4951a.tar.gz cpython-5bb059fe606983814a445e4dcf9e96fd7cb4951a.tar.bz2 |
GH-127236: `pathname2url()`: generate RFC 1738 URL for absolute POSIX path (#127194)
When handed an absolute Windows path such as `C:\foo` or `//server/share`,
the `urllib.request.pathname2url()` function returns a URL with an
authority section, such as `///C:/foo` or `//server/share` (or before
GH-126205, `////server/share`). Only the `file:` prefix is omitted.
But when handed an absolute POSIX path such as `/etc/hosts`, or a Windows
path of the same form (rooted but lacking a drive), the function returns a
URL without an authority section, such as `/etc/hosts`.
This patch corrects the discrepancy by adding a `//` prefix before
drive-less, rooted paths when generating URLs.
Diffstat (limited to 'Doc/library')
-rw-r--r-- | Doc/library/urllib.request.rst | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Doc/library/urllib.request.rst b/Doc/library/urllib.request.rst index 9055556..3c07dc4 100644 --- a/Doc/library/urllib.request.rst +++ b/Doc/library/urllib.request.rst @@ -159,12 +159,14 @@ The :mod:`urllib.request` module defines the following functions: 'file:///C:/Program%20Files' .. versionchanged:: 3.14 - Windows drive letters are no longer converted to uppercase. + Paths beginning with a slash are converted to URLs with authority + sections. For example, the path ``/etc/hosts`` is converted to + the URL ``///etc/hosts``. .. 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 - found in any position other than the second character. + Windows drive letters are no longer converted to uppercase, and ``:`` + characters not following a drive letter no longer cause an + :exc:`OSError` exception to be raised on Windows. .. function:: url2pathname(url) |