Skip to content

Commit 082c4bb

Browse files
authored
gh-88037: Update whatsnew section for the parsing difference in urlparse with non numeric port. (#162011)
gh-158956: Update whatsnew section for the parsing difference in urlparse with non numeric port.
1 parent 646673c commit 082c4bb

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

‎Doc/whatsnew/3.16.rst‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,6 +1415,28 @@ that may require changes to your code.
14151415
:exc:`TypeError`.
14161416
(Contributed by Serhiy Storchaka in :gh:`152587`.)
14171417

1418+
* :func:`urllib.parse.urlsplit` and :func:`urllib.parse.urlparse` now raise
1419+
:exc:`ValueError` when the URL is parsed if the port is not a decimal
1420+
number or is outside the range 0--65535. Previously, the error was only
1421+
raised when the :attr:`!port` attribute was read. This also affects
1422+
:func:`~urllib.parse.urljoin`, and :func:`~urllib.parse.urldefrag` for
1423+
URLs with a fragment. Code which never read :attr:`!port` may now fail
1424+
on URLs such as:
1425+
1426+
* SCP-style addresses given a scheme, such as
1427+
``git+ssh://git@github.com:org/repo.git``;
1428+
* multi-host URLs with ports, such as
1429+
``mongodb://h1:27017,h2:27017/db`` or
1430+
``postgresql://h1:5432,h2:5433/db``;
1431+
* URL templates with a placeholder port, such as
1432+
``http://localhost:{port}/``.
1433+
1434+
These are not valid URLs under :rfc:`3986`. To process them, split off
1435+
the netloc yourself before calling :func:`~urllib.parse.urlsplit`, for
1436+
example by replacing it with a placeholder host, or fill in templates
1437+
before parsing them.
1438+
(Contributed by Miguel Brito and Senthil Kumaran in :gh:`88037`.)
1439+
14181440
* :class:`uuid.UUID` now consistently raises :exc:`TypeError` when the
14191441
*bytes* or *bytes_le* argument is not a :class:`bytes` object.
14201442
Previously, some invalid inputs raised :exc:`AssertionError` or

0 commit comments

Comments
 (0)