https://github.com/python/cpython/commit/082c4bbfc2bfdac920a254fcb1b07ca12515f5e9 commit: 082c4bbfc2bfdac920a254fcb1b07ca12515f5e9 branch: main author: Senthil Kumaran <[email protected]> committer: orsenthil <[email protected]> date: 2026-11-14T17:00:18Z summary:
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. files: M Doc/whatsnew/3.16.rst diff --git a/Doc/whatsnew/3.16.rst b/Doc/whatsnew/3.16.rst index a7972d23e435af..ea9b27c27d78ed 100644 --- a/Doc/whatsnew/3.16.rst +++ b/Doc/whatsnew/3.16.rst @@ -1415,6 +1415,28 @@ that may require changes to your code. :exc:`TypeError`. (Contributed by Serhiy Storchaka in :gh:`152587`.) +* :func:`urllib.parse.urlsplit` and :func:`urllib.parse.urlparse` now raise + :exc:`ValueError` when the URL is parsed if the port is not a decimal + number or is outside the range 0--65535. Previously, the error was only + raised when the :attr:`!port` attribute was read. This also affects + :func:`~urllib.parse.urljoin`, and :func:`~urllib.parse.urldefrag` for + URLs with a fragment. Code which never read :attr:`!port` may now fail + on URLs such as: + + * SCP-style addresses given a scheme, such as + ``git+ssh://[email protected]:org/repo.git``; + * multi-host URLs with ports, such as + ``mongodb://h1:27017,h2:27017/db`` or + ``postgresql://h1:5432,h2:5433/db``; + * URL templates with a placeholder port, such as + ``http://localhost:{port}/``. + + These are not valid URLs under :rfc:`3986`. To process them, split off + the netloc yourself before calling :func:`~urllib.parse.urlsplit`, for + example by replacing it with a placeholder host, or fill in templates + before parsing them. + (Contributed by Miguel Brito and Senthil Kumaran in :gh:`88037`.) + * :class:`uuid.UUID` now consistently raises :exc:`TypeError` when the *bytes* or *bytes_le* argument is not a :class:`bytes` object. Previously, some invalid inputs raised :exc:`AssertionError` or _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
