Title: [3.12] Improve `pathname2url()` and `url2pathname()` docs (GH-127125) by miss-islington · Pull Request #127233 · python/cpython · GitHub
Open Graph Title: [3.12] Improve `pathname2url()` and `url2pathname()` docs (GH-127125) by miss-islington · Pull Request #127233 · python/cpython
X Title: [3.12] Improve `pathname2url()` and `url2pathname()` docs (GH-127125) by miss-islington · Pull Request #127233 · python/cpython
Description: These functions have long sown confusion among Python developers. The existing documentation says they deal with URL path components, but that doesn't fit the evidence on Windows: >>> pathname2url(r'C:\foo') '///C:/foo' >>> pathname2url(r'\\server\share') '////server/share' # or '//server/share' as of quite recently If these were URL path components, they would imply complete URLs like file://///C:/foo and file://////server/share. Clearly this isn't right. Yet the implementation in nturl2path is deliberate, and the url2pathname() function correctly inverts it. On non-Windows platforms, the behaviour until quite recently is to simply quote/unquote the path without adding or removing any leading slashes. This behaviour is compatible with both interpretations -- 1) the value is a URL path component (existing docs), and 2) the value is everything following file: (this commit) The conclusion I draw is that these functions operate on everything after the file: prefix, which may include an authority section. This is the only explanation that fits both the Windows and non-Windows behaviour. It's also a better match for the function names. (cherry picked from commit 307c633) Co-authored-by: Barney Gale barney.gale@gmail.com 📚 Documentation preview 📚: https://cpython-previews--127233.org.readthedocs.build/
Open Graph Description: These functions have long sown confusion among Python developers. The existing documentation says they deal with URL path components, but that doesn't fit the evidence on Windows: >>> ...
X Description: These functions have long sown confusion among Python developers. The existing documentation says they deal with URL path components, but that doesn't fit the evidence on Windows: >&...
Opengraph URL: https://github.com/python/cpython/pull/127233
X: @github
Domain: github.com
| 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 | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:e21937f0-dbad-5bdf-6d38-d0067151880c |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | CD1C:2E124E:472D393:5AB2E3D:6B0253F3 |
| html-safe-nonce | 5247bd50d3ce2092dc66f6993c6b8c5a6690f6f90387bac223796e6427843bf6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRDFDOjJFMTI0RTo0NzJEMzkzOjVBQjJFM0Q6NkIwMjUzRjMiLCJ2aXNpdG9yX2lkIjoiODA3NjIzNDM5NDcwMjA3NDg2NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 16a7b0bddc43c9923c8d129c0baf44d4cf7b55c763bc0a456c6586460833767c |
| hovercard-subject-tag | pull_request:2196887490 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/python/cpython/pull/127233/files |
| twitter:image | https://avatars.githubusercontent.com/u/31488909?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/31488909?s=400&v=4 |
| og:image:alt | These functions have long sown confusion among Python developers. The existing documentation says they deal with URL path components, but that doesn't fit the evidence on Windows: >>> ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 | true |
| 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 |
Links:
Viewport: width=device-width