Skip to content

Commit 26c8688

Browse files
committed
Docs + tests fixes
1 parent 0630a2d commit 26c8688

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

Doc/library/pathlib.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -872,10 +872,9 @@ conforming to :rfc:`8089`.
872872
.. versionadded:: 3.13
873873

874874
.. versionchanged:: next
875-
If a URL authority matches the current hostname, it is discarded.
876-
Otherwise, if the authority isn't empty or ``localhost``, then on
877-
Windows a UNC path is returned (as before), and on other platforms a
878-
:exc:`ValueError` is raised.
875+
The URL authority is discarded if it matches the machine hostname.
876+
Otherwise, on Windows a UNC path is returned (as before), and on other
877+
platforms a :exc:`ValueError` is raised.
879878

880879

881880
.. method:: Path.as_uri()

Doc/library/urllib.request.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,9 @@ The :mod:`urllib.request` module defines the following functions:
187187

188188
The URL authority is discarded if it empty, ``localhost``, or the current
189189
hostname. Otherwise, if *resolve_netloc* is set to true, the authority is
190-
resolved to an IP address using :func:`socket.gethostbyname`, and discarded
191-
if it matches a local IP. If the authority is still unhandled, then on
192-
Windows a UNC path is returned, and on other platforms a
190+
resolved using :func:`socket.gethostbyname`, and discarded if it matches a
191+
local IP address. If the authority is still unhandled, then on Windows a
192+
UNC path is returned, and on other platforms a
193193
:exc:`~urllib.error.URLError` is raised.
194194

195195
This example shows the function being used on Windows::

Lib/test/test_urllib.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1572,7 +1572,6 @@ def test_url2pathname_require_scheme_errors(self):
15721572
def test_url2pathname_resolve_netloc(self):
15731573
fn = urllib.request.url2pathname
15741574
sep = os.path.sep
1575-
self.assertRaises(urllib.error.URLError, fn, '//127.0.0.1/foo/bar')
15761575
self.assertEqual(fn('//127.0.0.1/foo/bar', resolve_netloc=True), f'{sep}foo{sep}bar')
15771576
self.assertEqual(fn(f'//{socket.gethostname()}/foo/bar'), f'{sep}foo{sep}bar')
15781577
self.assertEqual(fn(f'//{socket.gethostname()}/foo/bar', resolve_netloc=True), f'{sep}foo{sep}bar')
@@ -1607,6 +1606,7 @@ def test_url2pathname_win(self):
16071606
self.assertEqual(fn('//server/path/to/file'), '\\\\server\\path\\to\\file')
16081607
self.assertEqual(fn('////server/path/to/file'), '\\\\server\\path\\to\\file')
16091608
self.assertEqual(fn('/////server/path/to/file'), '\\\\server\\path\\to\\file')
1609+
self.assertEqual(fn('//127.0.0.1/path/to/file'), '\\\\127.0.0.1\\path\\to\\file')
16101610
# Localhost paths
16111611
self.assertEqual(fn('//localhost/C:/path/to/file'), 'C:\\path\\to\\file')
16121612
self.assertEqual(fn('//localhost/C|/path/to/file'), 'C:\\path\\to\\file')
@@ -1631,6 +1631,7 @@ def test_url2pathname_posix(self):
16311631
self.assertRaises(urllib.error.URLError, fn, '//:80/foo/bar')
16321632
self.assertRaises(urllib.error.URLError, fn, '//:/foo/bar')
16331633
self.assertRaises(urllib.error.URLError, fn, '//c:80/foo/bar')
1634+
self.assertRaises(urllib.error.URLError, fn, '//127.0.0.1/foo/bar')
16341635

16351636
@unittest.skipUnless(os_helper.FS_NONASCII, 'need os_helper.FS_NONASCII')
16361637
def test_url2pathname_nonascii(self):

0 commit comments

Comments
 (0)