Title: urllib.parse: port validation at parse time (gh-88037) breaks multi-host URLs; backported to 3.14 and 3.15 · Issue #161987 · python/cpython · GitHub
Open Graph Title: urllib.parse: port validation at parse time (gh-88037) breaks multi-host URLs; backported to 3.14 and 3.15 · Issue #161987 · python/cpython
X Title: urllib.parse: port validation at parse time (gh-88037) breaks multi-host URLs; backported to 3.14 and 3.15 · Issue #161987 · python/cpython
Description: Since gh-159122, urlsplit(), urlparse(), urljoin() and urldefrag() raise ValueError for any netloc whose port isn't a valid integer. That breaks URLs that worked before: >>> from urllib.parse import urlsplit >>> urlsplit('mongodb://h1:27...
Open Graph Description: Since gh-159122, urlsplit(), urlparse(), urljoin() and urldefrag() raise ValueError for any netloc whose port isn't a valid integer. That breaks URLs that worked before: >>> from urllib.parse impor...
X Description: Since gh-159122, urlsplit(), urlparse(), urljoin() and urldefrag() raise ValueError for any netloc whose port isn't a valid integer. That breaks URLs that worked before: >>> from urlli...
Mail addresses
git@github.com
Opengraph URL: https://github.com/python/cpython/issues/161987
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"urllib.parse: port validation at parse time (gh-88037) breaks multi-host URLs; backported to 3.14 and 3.15","articleBody":"Since gh-159122, `urlsplit()`, `urlparse()`, `urljoin()` and `urldefrag()` raise `ValueError` for any netloc whose port isn't a valid integer. That breaks URLs that worked before:\n\n```python\n>>> from urllib.parse import urlsplit\n>>> urlsplit('mongodb://h1:27017,h2:27017/db')\nValueError: Port could not be cast to integer value as '27017,h2:27017'\n```\n\nThe same happens with multi-host URLs for PostgreSQL (`postgresql://u@h1:5432,h2:5433/db`), Kafka and Redis Sentinel, with pip's `git+ssh://git@github.com:org/repo.git`, and with templates like `http://localhost:{port}/`. Code that only reads `.hostname` or `.path` used to work.\n\nThe change was backported to 3.14 (gh-161621) and 3.15 (gh-161619), but isn't released yet (3.14.10 and 3.15.2 don't have it), so it would first ship in 3.14.11 and 3.15.3. Could the backports be reverted, since this is a behaviour change in bugfix releases? For main, maybe a deprecation period first.\n\nI've opened PRs that revert the two backports.\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-161988\n* gh-161989\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/thejesh23","@type":"Person","name":"thejesh23"},"datePublished":"2026-11-14T06:57:41Z","url":"https://github.com/python/cpython/issues/161987"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:093b9094-b9f4-ac48-7a12-6222cbd94082 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D4F6:34CAB:43C1E0E:567D5E3:6B0241BC |
| html-safe-nonce | 71c4c022843c205bfa69c92256a203c9749c7681146d86ccd25a58ca5c7a9521 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENEY2OjM0Q0FCOjQzQzFFMEU6NTY3RDVFMzo2QjAyNDFCQyIsInZpc2l0b3JfaWQiOiIzODczMjc5NzU5MzM3Mjc1ODM2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | ee124eb7086c30b8103c2f29a1cd0815da88a92edb843e44726b693ab1b83062 |
| hovercard-subject-tag | issue:6386607927 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/161987/issue_layout |
| twitter:image | https://opengraph.githubassets.com/153d50c75e601ae591942f5dc27fbf93191deb1b42732df1001e364a3346db69/python/cpython/issues/161987 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/153d50c75e601ae591942f5dc27fbf93191deb1b42732df1001e364a3346db69/python/cpython/issues/161987 |
| og:image:alt | Since gh-159122, urlsplit(), urlparse(), urljoin() and urldefrag() raise ValueError for any netloc whose port isn't a valid integer. That breaks URLs that worked before: >>> from urllib.parse impor... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | thejesh23 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width