File tree Expand file tree Collapse file tree 4 files changed +11
-13
lines changed Expand file tree Collapse file tree 4 files changed +11
-13
lines changed Original file line number Diff line number Diff line change @@ -872,11 +872,10 @@ conforming to :rfc:`8089`.
872872 .. versionadded :: 3.13
873873
874874 .. versionchanged :: next
875- If a URL authority (e.g. a hostname) is present and resolves to
876- ``localhost ``, it is discarded. If an authority is present and
877- *doesn't * resolve to ``localhost ``, then on Windows a UNC path is
878- returned (as before), and on other platforms a :exc: `ValueError ` is
879- raised.
875+ If a URL authority (e.g. a hostname) is present and resolves to a local
876+ address, it is discarded. If an authority is present and *doesn't *
877+ resolve to a local address, then on Windows a UNC path is returned (as
878+ before), and on other platforms a :exc: `ValueError ` is raised.
880879
881880.. method :: Path.as_uri()
882881
Original file line number Diff line number Diff line change @@ -182,11 +182,10 @@ The :mod:`urllib.request` module defines the following functions:
182182 'C:\\Program Files'
183183
184184 .. versionchanged :: next
185- If a URL authority (e.g. a hostname) is present and resolves to
186- ``localhost ``, it is discarded. If an authority is present and
187- *doesn't * resolve to ``localhost ``, then on Windows a UNC path is
188- returned (as before), and on other platforms a
189- :exc: `~urllib.error.URLError ` is raised.
185+ If a URL authority (e.g. a hostname) is present and resolves to a local
186+ address, it is discarded. If an authority is present and *doesn't *
187+ resolve to a local address, then on Windows a UNC path is returned (as
188+ before), and on other platforms :exc: `~urllib.error.URLError ` is raised.
190189
191190 .. versionchanged :: 3.14
192191 Windows drive letters are no longer converted to uppercase, and ``: ``
Original file line number Diff line number Diff line change @@ -1002,7 +1002,7 @@ urllib
10021002
10031003 In :func: `urllib.request.url2pathname `:
10041004
1005- - Discard URL authorities that resolve to `` localhost `` .
1005+ - Discard URL authorities that resolve to a local address .
10061006 - Raise :exc: `~urllib.error.URLError ` if a URL authority doesn't resolve
10071007 to ``localhost ``, except on Windows where we return a UNC path.
10081008
Original file line number Diff line number Diff line change @@ -1483,11 +1483,11 @@ def _is_local_authority(authority):
14831483 return False
14841484 if _local_addresses is None :
14851485 try :
1486- _local_addresses = tuple (
1486+ _local_addresses = frozenset (
14871487 socket .gethostbyname_ex ('localhost' )[2 ] +
14881488 socket .gethostbyname_ex (socket .gethostname ())[2 ])
14891489 except socket .gaierror :
1490- _local_addresses = (socket .gethostbyname ('localhost' ),)
1490+ _local_addresses = frozenset (socket .gethostbyname ('localhost' ),)
14911491 return address in _local_addresses
14921492
14931493class FTPHandler (BaseHandler ):
You can’t perform that action at this time.
0 commit comments