Skip to content

gh-64470: Validate the port in urlsplit() and urlparse() - #155220

Draft
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:gh-64470-urlsplit-port
Draft

gh-64470: Validate the port in urlsplit() and urlparse()#155220
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:gh-64470-urlsplit-port

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

urlsplit() and urlparse() now raise ValueError for an URL with an invalid port, instead of failing only when the port attribute of the result is read. This also rejects URLs with an unbracketed IPv6 address, like "http://::1/".

Reading the port attribute of a result object created directly still raises ValueError.

urlsplit() and urlparse() now raise ValueError for an URL with an invalid
port, instead of failing only when the port attribute of the result is
read.  This also rejects URLs with an unbracketed IPv6 address, like
"http://::1/".

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@serhiy-storchaka serhiy-storchaka added stdlib Standard Library Python modules in the Lib/ directory type-bug An unexpected behavior, bug, or error labels Aug 5, 2026
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33921564 | 📁 Comparing c88f078 against main (3874ad1)

  🔍 Preview build  

2 files changed
± library/urllib.parse.html
± whatsnew/changelog.html

@serhiy-storchaka serhiy-storchaka removed type-bug An unexpected behavior, bug, or error stdlib Standard Library Python modules in the Lib/ directory labels Aug 5, 2026
@serhiy-storchaka
serhiy-storchaka marked this pull request as draft August 5, 2026 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant