René's URL Explorer Experiment


Title: [WIP] GH-65238: Preserve trailing slash in pathlib by barneygale · Pull Request #112363 · python/cpython · GitHub

Open Graph Title: [WIP] GH-65238: Preserve trailing slash in pathlib by barneygale · Pull Request #112363 · python/cpython

X Title: [WIP] GH-65238: Preserve trailing slash in pathlib by barneygale · Pull Request #112363 · python/cpython

Description: Fix the last known case where pathlib can mangle the meaning of a path. This brings pathlib in line with IEEE Std 1003.1-2017, where trailing slashes are meaningful to path resolution and should not be discarded. Changes In several important respects, paths with trailing slashes behave differently to their slash-less counterparts: Paths with and without trailing slashes compare unequal and generate different hash codes __str__(), __fspath__() and related representations include any trailing slash glob() patterns ending with a slash will now generate results ending with a slash, matching glob.glob() behaviour match() now observes trailing slashes, and so its pattern language exactly matches that of glob(). To manipulate a trailing slash, we add these new methods/properties: has_trailing_sep - read-only boolean indicating whether a trailing slash is present with_trailing_sep() - returns a new path with a trailing slash present without_trailing_sep() - returns a new path with a trailing slash omitted Backwards compatibility Empty segments given to the PurePath initialiser do not generate new segments, so str(PurePath("foo", "")) results in "foo", not "foo/". Methods concerned with dirnames and basenames ignore any trailing slash: name, stem, suffix and suffixes retrieve the last non-empty path segment, and so any trailing slash are ignored with_name(), with_stem() and with_suffix() replace the last non-empty path segment parent and parents ignore any trailing slash relative_to() and is_relative_to() ignore any trailing slashes in self and other. The .parts tuple works exactly as before, and doesn't distinguish paths with trailing separators Not sure if this is right tbh Dependencies #112362 #112365 #112676 #113248 Future work Once this lands, we can take advantage of the fact that pathlib does not mangle paths. Thus: We can make __fspath__() return an unnormalized path for a tasty speed boost in many applications #102783 We can call into pathlib from shutil, which means we can add methods like chown(), move() and rmtree() without code duplication #64978 #73991 Issue: gh-65238

Open Graph Description: Fix the last known case where pathlib can mangle the meaning of a path. This brings pathlib in line with IEEE Std 1003.1-2017, where trailing slashes are meaningful to path resolution and should no...

X Description: Fix the last known case where pathlib can mangle the meaning of a path. This brings pathlib in line with IEEE Std 1003.1-2017, where trailing slashes are meaningful to path resolution and should no...

Opengraph URL: https://github.com/python/cpython/pull/112363

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:51e714ab-f151-fc3a-9a74-0365925b1792
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idB39E:C9E9C:1406672:1BF8DBC:696A3691
html-safe-noncea42c46cd3d84b972809c509c0cac3580488e5414f57fc32adc177fb9ece6018f
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMzlFOkM5RTlDOjE0MDY2NzI6MUJGOERCQzo2OTZBMzY5MSIsInZpc2l0b3JfaWQiOiIxNDg2MjA0ODc4MjgxMzg5NzEzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac94f3d4daf07bd5b7859299766b7607b352107036ffcf09274a75a2959911de63
hovercard-subject-tagpull_request:1615514710
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/cpython/pull/112363/files
twitter:imagehttps://avatars.githubusercontent.com/u/960340?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/960340?s=400&v=4
og:image:altFix the last known case where pathlib can mangle the meaning of a path. This brings pathlib in line with IEEE Std 1003.1-2017, where trailing slashes are meaningful to path resolution and should no...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None321736bfdb3f591415ae895a0459bec204b26a76caf47ba5c980634cfacc4538
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release7a9163cefd1ea4bd06f8eb7c082f43e4e53f626f
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/112363/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F112363%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F112363%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/pull/112363/files
Reloadhttps://github.com/python/cpython/pull/112363/files
Reloadhttps://github.com/python/cpython/pull/112363/files
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/112363/files
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 33.9k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 71.1k https://github.com/login?return_to=%2Fpython%2Fcpython
Code https://github.com/python/cpython
Issues 5k+ https://github.com/python/cpython/issues
Pull requests 2.1k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects 31 https://github.com/python/cpython/projects
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/python/cpython/security
Please reload this pagehttps://github.com/python/cpython/pull/112363/files
Insights https://github.com/python/cpython/pulse
Code https://github.com/python/cpython
Issues https://github.com/python/cpython/issues
Pull requests https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
barneygalehttps://github.com/barneygale
python:mainhttps://github.com/python/cpython/tree/main
barneygale:keep-trailing-slash-wip3https://github.com/barneygale/cpython/tree/keep-trailing-slash-wip3
Conversation 0 https://github.com/python/cpython/pull/112363
Commits 31 https://github.com/python/cpython/pull/112363/commits
Checks 0 https://github.com/python/cpython/pull/112363/checks
Files changed https://github.com/python/cpython/pull/112363/files
Please reload this pagehttps://github.com/python/cpython/pull/112363/files
[WIP] GH-65238: Preserve trailing slash in pathlib https://github.com/python/cpython/pull/112363/files#top
Show all changes 31 commits https://github.com/python/cpython/pull/112363/files
a1326c8 GH-65238: Preserve trailing slash in pathlib barneygale Nov 24, 2023 https://github.com/python/cpython/pull/112363/commits/a1326c8c5f6dfb2d402f9346583accfa12552989
df1e115 Fix absolute() on bare DOS drive barneygale Nov 24, 2023 https://github.com/python/cpython/pull/112363/commits/df1e1158392edf56b35a40c77c0819042be772b7
61be2e3 Simplify diff barneygale Nov 24, 2023 https://github.com/python/cpython/pull/112363/commits/61be2e385694fece50ccb723c1ecf0fbc613d60a
445364a Reduce diff barneygale Nov 24, 2023 https://github.com/python/cpython/pull/112363/commits/445364a1262da2995803d3c58ad4677f80048ed6
6395815 Speed up _make_child_relpath() barneygale Nov 24, 2023 https://github.com/python/cpython/pull/112363/commits/63958156efd4c27b13086470d65d016ea431d3f2
435be1b Ignore empty initialiser arguments for backwards compat barneygale Nov 25, 2023 https://github.com/python/cpython/pull/112363/commits/435be1b5823a50b3c1627e7238cb92164cbddd99
e577a67 Merge branch 'main' into keep-trailing-slash-wip3 barneygale Nov 25, 2023 https://github.com/python/cpython/pull/112363/commits/e577a67177bc8cc063876f381597be8820427af0
d766d06 Simplify implementation barneygale Dec 1, 2023 https://github.com/python/cpython/pull/112363/commits/d766d068d67171522d933343993a1307f25d4c97
12cfb1a Merge branch 'main' into keep-trailing-slash-wip3 barneygale Dec 2, 2023 https://github.com/python/cpython/pull/112363/commits/12cfb1a4aedd0dd0c5420d87f275990181932e4c
2593ddb Merge branch 'main' into keep-trailing-slash-wip3 barneygale Dec 3, 2023 https://github.com/python/cpython/pull/112363/commits/2593ddbd385f29ff8d502394adc7632020443fe2
b275078 Add tests barneygale Dec 3, 2023 https://github.com/python/cpython/pull/112363/commits/b27507899b622e6884f5b1d6abef7b3c83fa8e2a
5d87cf4 Docstrings barneygale Dec 4, 2023 https://github.com/python/cpython/pull/112363/commits/5d87cf400d0aa49344cef8aacc0f7f89423eeee1
af12c24 Docs barneygale Dec 4, 2023 https://github.com/python/cpython/pull/112363/commits/af12c24bb4f2e27c1a834cc84b3f6f64f399cf37
cae3774 Ensure has_trailing_sep is boolean barneygale Dec 4, 2023 https://github.com/python/cpython/pull/112363/commits/cae377495adfc2937d88e611cab85500844b4596
d4c87c6 Add tests for new methods/properties barneygale Dec 4, 2023 https://github.com/python/cpython/pull/112363/commits/d4c87c6462d7975d00374ce5995ba00a8c67fcb1
1a77c8a Fix WindowsPath('C:').absolute() barneygale Dec 4, 2023 https://github.com/python/cpython/pull/112363/commits/1a77c8a745c4121d926d428b4cdba03b1ef122aa
120beed Merge branch 'main' into keep-trailing-slash-wip3 barneygale Dec 4, 2023 https://github.com/python/cpython/pull/112363/commits/120beed845a745b9e74ac3599353793d5f90eae5
df79c49 Don't access `.parts` from `._glob()` barneygale Dec 7, 2023 https://github.com/python/cpython/pull/112363/commits/df79c49ad49c8110823ec6a311265d4508cf7f24
0f75804 Fix pickle roundtripping barneygale Dec 7, 2023 https://github.com/python/cpython/pull/112363/commits/0f75804f52d2754c652e3faa4b7711cef374ab48
eeb35ff Undo changes to `parts` barneygale Dec 7, 2023 https://github.com/python/cpython/pull/112363/commits/eeb35ffa0472ca09364141064656eb1f786ccc7c
153c4af Merge branch 'main' into keep-trailing-slash-wip3 barneygale Dec 7, 2023 https://github.com/python/cpython/pull/112363/commits/153c4afe81e6c21ac1288629a2f9ebcb861256dc
b852339 Simplify `_glob()` slightly barneygale Dec 7, 2023 https://github.com/python/cpython/pull/112363/commits/b852339e2f1ed74b5a03ce454cee5b13efed508d
2b77a61 Fix possible scoping issue in `_glob()` barneygale Dec 7, 2023 https://github.com/python/cpython/pull/112363/commits/2b77a61faf44ccce7fbc92279fcf3a3d0ba034f5
7b6766f Formatting barneygale Dec 8, 2023 https://github.com/python/cpython/pull/112363/commits/7b6766f59c0f7efa3ab7bde42f1c6649ec25f960
f5c2265 Add test cases for preserving slash in absolute() and expanduser() barneygale Dec 8, 2023 https://github.com/python/cpython/pull/112363/commits/f5c226577f66c24349d9127c1fb5dbb85bfde0a4
1126117 Add notes to `match()` and `glob()` docs barneygale Dec 8, 2023 https://github.com/python/cpython/pull/112363/commits/11261172eb026205fd36c12415d6e90a90df8b57
9c9b5ea Merge branch 'main' into keep-trailing-slash-wip3 barneygale Dec 8, 2023 https://github.com/python/cpython/pull/112363/commits/9c9b5eaa621b897b2099eca9c54a3fce74892b86
9539c60 Merge branch 'main' into keep-trailing-slash-wip3 barneygale Dec 11, 2023 https://github.com/python/cpython/pull/112363/commits/9539c603f6d5656ea2d43fb801546658cab427e7
14a9635 Merge branch 'main' into keep-trailing-slash-wip3 barneygale Dec 17, 2023 https://github.com/python/cpython/pull/112363/commits/14a9635b4f6091e0ebe36535efedb47d03b8428a
305381b Undo pickling change barneygale Dec 17, 2023 https://github.com/python/cpython/pull/112363/commits/305381b32521ae1e5e0702f8b89f3cf12ecdbb3e
dfe7aae Undo pickling changes. barneygale Dec 18, 2023 https://github.com/python/cpython/pull/112363/commits/dfe7aae5884258b3f85d675a3b83cd1b44133bda
Clear filters https://github.com/python/cpython/pull/112363/files
Please reload this pagehttps://github.com/python/cpython/pull/112363/files
Please reload this pagehttps://github.com/python/cpython/pull/112363/files
pathlib.rst https://github.com/python/cpython/pull/112363/files#diff-1134e36a94ecfde1df43bee5efd285de5d67426fbca086425201ecc753f9139c
__init__.py https://github.com/python/cpython/pull/112363/files#diff-2282b1d4074c3cc317f8490ac16730aef232a3a125b8acfc49232dcd6c4f6d88
_abc.py https://github.com/python/cpython/pull/112363/files#diff-80172c23421c1dd13d79623c67c24cee61b300f18a55ab5d2d33d69d490abe9a
test_pathlib.py https://github.com/python/cpython/pull/112363/files#diff-03d884d0a180340cc959b85206069287a4720ba88da9463cc94f79396d0f8f9c
test_pathlib_abc.py https://github.com/python/cpython/pull/112363/files#diff-4669f270f5520190bbc1c9e99ac03db2847c44be835fb3d2d9ff727d73761f58
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L525
Doc/library/pathlib.rsthttps://github.com/python/cpython/pull/112363/files#diff-1134e36a94ecfde1df43bee5efd285de5d67426fbca086425201ecc753f9139c
View file https://github.com/barneygale/cpython/blob/dfe7aae5884258b3f85d675a3b83cd1b44133bda/Doc/library/pathlib.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/112363/{{ revealButtonHref }}
https://github.com/python/cpython/pull/112363/files#diff-1134e36a94ecfde1df43bee5efd285de5d67426fbca086425201ecc753f9139c
https://github.com/python/cpython/pull/112363/files#diff-1134e36a94ecfde1df43bee5efd285de5d67426fbca086425201ecc753f9139c
https://github.com/python/cpython/pull/112363/files#diff-1134e36a94ecfde1df43bee5efd285de5d67426fbca086425201ecc753f9139c
https://github.com/python/cpython/pull/112363/files#diff-1134e36a94ecfde1df43bee5efd285de5d67426fbca086425201ecc753f9139c
https://github.com/python/cpython/pull/112363/files#diff-1134e36a94ecfde1df43bee5efd285de5d67426fbca086425201ecc753f9139c
https://github.com/python/cpython/pull/112363/files#diff-1134e36a94ecfde1df43bee5efd285de5d67426fbca086425201ecc753f9139c
https://github.com/python/cpython/pull/112363/files#diff-1134e36a94ecfde1df43bee5efd285de5d67426fbca086425201ecc753f9139c
https://github.com/python/cpython/pull/112363/files#diff-1134e36a94ecfde1df43bee5efd285de5d67426fbca086425201ecc753f9139c
https://github.com/python/cpython/pull/112363/files#diff-1134e36a94ecfde1df43bee5efd285de5d67426fbca086425201ecc753f9139c
https://github.com/python/cpython/pull/112363/files#diff-1134e36a94ecfde1df43bee5efd285de5d67426fbca086425201ecc753f9139c
https://github.com/python/cpython/pull/112363/files#diff-1134e36a94ecfde1df43bee5efd285de5d67426fbca086425201ecc753f9139c
https://github.com/python/cpython/pull/112363/files#diff-1134e36a94ecfde1df43bee5efd285de5d67426fbca086425201ecc753f9139c
https://github.com/python/cpython/pull/112363/files#diff-1134e36a94ecfde1df43bee5efd285de5d67426fbca086425201ecc753f9139c
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L526
Lib/pathlib/__init__.pyhttps://github.com/python/cpython/pull/112363/files#diff-2282b1d4074c3cc317f8490ac16730aef232a3a125b8acfc49232dcd6c4f6d88
View file https://github.com/barneygale/cpython/blob/dfe7aae5884258b3f85d675a3b83cd1b44133bda/Lib/pathlib/__init__.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/112363/{{ revealButtonHref }}
https://github.com/python/cpython/pull/112363/files#diff-2282b1d4074c3cc317f8490ac16730aef232a3a125b8acfc49232dcd6c4f6d88
https://github.com/python/cpython/pull/112363/files#diff-2282b1d4074c3cc317f8490ac16730aef232a3a125b8acfc49232dcd6c4f6d88
https://github.com/python/cpython/pull/112363/files#diff-2282b1d4074c3cc317f8490ac16730aef232a3a125b8acfc49232dcd6c4f6d88
https://github.com/python/cpython/pull/112363/files#diff-2282b1d4074c3cc317f8490ac16730aef232a3a125b8acfc49232dcd6c4f6d88
https://github.com/python/cpython/pull/112363/files#diff-2282b1d4074c3cc317f8490ac16730aef232a3a125b8acfc49232dcd6c4f6d88
https://github.com/python/cpython/pull/112363/files#diff-2282b1d4074c3cc317f8490ac16730aef232a3a125b8acfc49232dcd6c4f6d88
https://github.com/python/cpython/pull/112363/files#diff-2282b1d4074c3cc317f8490ac16730aef232a3a125b8acfc49232dcd6c4f6d88
Please reload this pagehttps://github.com/python/cpython/pull/112363/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.