Title: `urllib.request.pathname2url()`: generate RFC 1738 URLs where possible · Issue #127236 · python/cpython · GitHub
Open Graph Title: `urllib.request.pathname2url()`: generate RFC 1738 URLs where possible · Issue #127236 · python/cpython
X Title: `urllib.request.pathname2url()`: generate RFC 1738 URLs where possible · Issue #127236 · python/cpython
Description: Feature or enhancement Proposal: urllib.request.pathname2url currently generates RFC 1738-compliant file: URIs in the following cases: DOS drive paths (including drive-relative paths) on Windows. UNC paths on Windows. POSIX paths beginni...
Open Graph Description: Feature or enhancement Proposal: urllib.request.pathname2url currently generates RFC 1738-compliant file: URIs in the following cases: DOS drive paths (including drive-relative paths) on Windows. U...
X Description: Feature or enhancement Proposal: urllib.request.pathname2url currently generates RFC 1738-compliant file: URIs in the following cases: DOS drive paths (including drive-relative paths) on Windows. U...
Opengraph URL: https://github.com/python/cpython/issues/127236
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`urllib.request.pathname2url()`: generate RFC 1738 URLs where possible","articleBody":"# Feature or enhancement\r\n\r\n### Proposal:\r\n\r\n[`urllib.request.pathname2url`](https://docs.python.org/3/library/urllib.request.html#urllib.request.pathname2url) currently generates [RFC 1738](https://www.rfc-editor.org/rfc/rfc1738#section-3.10)-compliant `file:` URIs in the following cases:\r\n\r\n- DOS drive paths (including drive-relative paths) on Windows.\r\n- UNC paths on Windows.\r\n- POSIX paths beginning `//` (since GH-127217)\r\n\r\nThis function _cannot_ generate RFC 1738-compliant URLs for:\r\n\r\n- True relative paths, because of differing requirements for the first character of the path.\r\n\r\nThat leaves one case where the function _could_ generate RFC 1738-compatible URLs, but doesn't:\r\n\r\n- Paths beginning with exactly one slash (both POSIX and Windows)\r\n\r\n```python\r\n>>> from urllib.request import pathname2url\r\n>>> pathname2url('/etc/hosts')\r\n'/etc/hosts' # expected: '///etc/hosts'\r\n```\r\n\r\nFor consistency with `pathname2url()`'s handling of other paths, and consistency with [`pathlib.Path.as_uri()`](https://docs.python.org/3/library/pathlib.html#pathlib.Path.as_uri), I propose we prepend two slashes to any path beginning with precisely one slash to produce a URL authority section with a zero-length authority.\r\n\r\n### Has this already been discussed elsewhere?\r\n\r\nThis is a minor feature, which does not need previous discussion elsewhere\r\n\r\n### Links to previous discussion of this feature:\r\n\r\nhttps://github.com/python/cpython/issues/125866#issuecomment-2495919168\r\n\r\n\u003c!-- gh-linked-prs -->\r\n### Linked PRs\r\n* gh-127194\r\n\u003c!-- /gh-linked-prs -->\r\n","author":{"url":"https://github.com/barneygale","@type":"Person","name":"barneygale"},"datePublished":"2024-11-24T18:52:49Z","url":"https://github.com/python/cpython/issues/127236"}
| 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:c5d1f378-804e-9180-0d1d-fb6a1c982362 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A24E:88BC0:331781:3FA4A6:6B023A67 |
| html-safe-nonce | 4c47c516fa67ea258e00bc3bee0f487bad84a4b7ba1719d599f13318cd053d95 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMjRFOjg4QkMwOjMzMTc4MTozRkE0QTY6NkIwMjNBNjciLCJ2aXNpdG9yX2lkIjoiMjcxNjMxMzA5MTMyMjI5NjkzNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 51611f791fee3e55644e54cab8c2b75beb29462a0efc1f8105c722af7ed8480c |
| hovercard-subject-tag | issue:2688206000 |
| 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/127236/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e2d72a884449999a03d105aa8c0ba78edcdd5a1032cc0b1bb0e6079d4dbb13b4/python/cpython/issues/127236 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e2d72a884449999a03d105aa8c0ba78edcdd5a1032cc0b1bb0e6079d4dbb13b4/python/cpython/issues/127236 |
| og:image:alt | Feature or enhancement Proposal: urllib.request.pathname2url currently generates RFC 1738-compliant file: URIs in the following cases: DOS drive paths (including drive-relative paths) on Windows. U... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | barneygale |
| 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