René's URL Explorer Experiment


Title: gh-68320, gh-88302 - Allow for `pathlib.Path` subclassing by barneygale · Pull Request #31691 · python/cpython · GitHub

Open Graph Title: gh-68320, gh-88302 - Allow for `pathlib.Path` subclassing by barneygale · Pull Request #31691 · python/cpython

X Title: gh-68320, gh-88302 - Allow for `pathlib.Path` subclassing by barneygale · Pull Request #31691 · python/cpython

Description: Users may wish to define subclasses of pathlib.PurePath and Path to add or modify existing methods. Before this change, attempting to instantiate a subclass raised an exception like: AttributeError: type object 'PPath' has no attribute '_flavour' Previously the _flavour attribute was assigned as follows: PurePath._flavour = xxx not set!! xxx PurePosixPath._flavour = _PosixFlavour() PureWindowsPath._flavour = _WindowsFlavour() It's now set as follows: PurePath._flavour = os.path PurePosixPath._flavour = posixpath PureWindowsPath._flavour = ntpath Functionality from _PosixFlavour and _WindowsFlavour is moved into PurePath as underscored-prefixed classmethods. Flavour classes are removed. A deeper dive into this patch can be read here: https://discuss.python.org/t/make-pathlib-extensible/3428/42 Fixes #68320 #88302 Issue: gh-68320

Open Graph Description: Users may wish to define subclasses of pathlib.PurePath and Path to add or modify existing methods. Before this change, attempting to instantiate a subclass raised an exception like: AttributeError...

X Description: Users may wish to define subclasses of pathlib.PurePath and Path to add or modify existing methods. Before this change, attempting to instantiate a subclass raised an exception like: AttributeError...

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

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:6f4ab600-405f-98a7-2250-91424f659633
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idE926:5177D:2129254:2E361BB:69693D4B
html-safe-noncead71e3bfe8dcb0f35932a2c375a5a406992c9c62dba8aafa9d8660b3ce9bd305
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOTI2OjUxNzdEOjIxMjkyNTQ6MkUzNjFCQjo2OTY5M0Q0QiIsInZpc2l0b3JfaWQiOiIxMTE2MTkwOTM2MjA2Njk3NzEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac1a993bdd239f308e4211bba5139168bc5e8c1203f2c2d3ed63c2d6af84b2dfff
hovercard-subject-tagpull_request:872134193
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/31691/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:altUsers may wish to define subclasses of pathlib.PurePath and Path to add or modify existing methods. Before this change, attempting to instantiate a subclass raised an exception like: AttributeError...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None54182691a21263b584d2e600b758e081b0ff1d10ffc0d2eefa51cf754b43b51d
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
released69ac0477df0f87da03b8b06cebd187012d7a930
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/31691/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F31691%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%2F31691%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/31691/files
Reloadhttps://github.com/python/cpython/pull/31691/files
Reloadhttps://github.com/python/cpython/pull/31691/files
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/31691/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 2k 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/31691/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
brettcannonhttps://github.com/brettcannon
python:mainhttps://github.com/python/cpython/tree/main
barneygale:bpo-44136-remove-pathlib-flavour-2https://github.com/barneygale/cpython/tree/bpo-44136-remove-pathlib-flavour-2
Conversation 172 https://github.com/python/cpython/pull/31691
Commits 53 https://github.com/python/cpython/pull/31691/commits
Checks 0 https://github.com/python/cpython/pull/31691/checks
Files changed https://github.com/python/cpython/pull/31691/files
Please reload this pagehttps://github.com/python/cpython/pull/31691/files
gh-68320, gh-88302 - Allow for pathlib.Path subclassing https://github.com/python/cpython/pull/31691/files#top
Show all changes 53 commits https://github.com/python/cpython/pull/31691/files
7371220 bpo-24132, bpo-44136 - Fix `pathlib.Path` subclassing. barneygale Mar 5, 2022 https://github.com/python/cpython/pull/31691/commits/7371220586c8367d80867f340381740347d7aea1
8431d12 Add tests barneygale Mar 5, 2022 https://github.com/python/cpython/pull/31691/commits/8431d1214140a9a1ab02b178bdf84bf083dd2425
bf2ad3a Add tests for PurePath subclasses barneygale Mar 5, 2022 https://github.com/python/cpython/pull/31691/commits/bf2ad3aead98c85b181c5cae2541135e0f110523
4036e2e Update Misc/NEWS.d/next/Library/2022-03-05-02-14-09.bpo-24132.W6iORO.rst barneygale Mar 5, 2022 https://github.com/python/cpython/pull/31691/commits/4036e2e955cc9720447f7b3700a2b9b755e32cf2
0d08533 Rename `PurePath._pathmod` to `PurePath._flavour` to reduce the diff. barneygale Mar 5, 2022 https://github.com/python/cpython/pull/31691/commits/0d08533ca9c4938873ff826ea098cacef0d2374d
0ad8022 Merge branch 'bpo-44136-remove-pathlib-flavour-2' of github.com:barne… barneygale Mar 5, 2022 https://github.com/python/cpython/pull/31691/commits/0ad8022acfc0389e3c976c2e43b364762dc7278b
28992fc Undo an unnecessary change to `Path.__new__()` barneygale Mar 25, 2022 https://github.com/python/cpython/pull/31691/commits/28992fc69d90afe67b99ba967ea28250d565af30
dbec230 Remove `_casefold()` and `_casefold_parts()` methods. barneygale Mar 25, 2022 https://github.com/python/cpython/pull/31691/commits/dbec2300fe7010282b78a64284b08073d35ec6d4
d814ee4 Merge branch 'main' into bpo-44136-remove-pathlib-flavour-2 barneygale Apr 29, 2022 https://github.com/python/cpython/pull/31691/commits/d814ee4b4cd01ca15a6e74f5e9262a9abda18cfc
63f1d68 Further simplify overall diff by inlining code from `compile_pattern()` barneygale Apr 29, 2022 https://github.com/python/cpython/pull/31691/commits/63f1d6834f7087881c3704ae2fa6a2842cdf3815
8dddfdf Apply suggestions from code review barneygale Apr 29, 2022 https://github.com/python/cpython/pull/31691/commits/8dddfdf995791e1cc081078cb73b79f2f35488f9
b4da721 Address a couple bits of review feedback barneygale Apr 29, 2022 https://github.com/python/cpython/pull/31691/commits/b4da721300395af003f1237d071c7e14bfb1925a
7a166fd Fix tests barneygale Apr 29, 2022 https://github.com/python/cpython/pull/31691/commits/7a166fdb493d59b20d3b323cfb9e1b93930c4261
1f4dff1 Fix docstring formatting. barneygale Apr 29, 2022 https://github.com/python/cpython/pull/31691/commits/1f4dff11b267ef0f94f0930a8ece44bccea0df6f
51893c1 Remove FIXME comments barneygale Apr 30, 2022 https://github.com/python/cpython/pull/31691/commits/51893c11c5e794f1072acbe57b0ae921a431c33d
48b49b6 Merge branch 'main' into bpo-44136-remove-pathlib-flavour-2 barneygale Apr 30, 2022 https://github.com/python/cpython/pull/31691/commits/48b49b624753a9a3f73e225700f81ad21b93b6e4
3624c97 Update Lib/pathlib.py barneygale May 3, 2022 https://github.com/python/cpython/pull/31691/commits/3624c974507457b00bc7a24531fcca2f0961ea55
ab54c14 Remove vestigal 'casefold' names. barneygale May 31, 2022 https://github.com/python/cpython/pull/31691/commits/ab54c14661b0c98d79be140e2be4ac718b05568f
2627417 Merge branch 'main' into bpo-44136-remove-pathlib-flavour-2 barneygale Jun 10, 2022 https://github.com/python/cpython/pull/31691/commits/2627417656b5e4a39c1936e4440aa448757a4bc8
bc7aded Restore comment on POSIX paths beginning `//` and tweak implementation. barneygale Jun 10, 2022 https://github.com/python/cpython/pull/31691/commits/bc7aded29a523bdd580d7f329ad88d89131f9695
4d6e4f3 Inline `_join_parsed_parts()` and `_make_child()` in `joinpath()`. barneygale Jun 12, 2022 https://github.com/python/cpython/pull/31691/commits/4d6e4f3ee6d6017a59cfc0ea8a9e27653c28332e
70ca838 Update Lib/pathlib.py barneygale Jun 13, 2022 https://github.com/python/cpython/pull/31691/commits/70ca8388163f876c6f2d4aa491dd8d504aca7bb4
a2cc74f Remove unused import barneygale Jun 16, 2022 https://github.com/python/cpython/pull/31691/commits/a2cc74f3dd9b28baee80e77cda8517566d74758e
0e2478b Make NEWS entry more precise. barneygale Jun 17, 2022 https://github.com/python/cpython/pull/31691/commits/0e2478bbac3c60e7b3d116d0fb3b69f11da49476
0d0cf60 Apply suggestions from code review barneygale Jul 29, 2022 https://github.com/python/cpython/pull/31691/commits/0d0cf6012cd0aae28f923ab99ab05c04f2d78c94
f3048d3 Clarify `_pparts` and `_ncparts` naming. barneygale Jul 29, 2022 https://github.com/python/cpython/pull/31691/commits/f3048d312d72e9f1cac381aab8238c702a640161
8a213ae Tidy up usage of `normcase()` barneygale Jul 30, 2022 https://github.com/python/cpython/pull/31691/commits/8a213ae1d5600d383451950c2a634d9b601d8987
402dafe Tweak `is_absolute()` to use `os.path.isabs()` wherever possible. barneygale Jul 30, 2022 https://github.com/python/cpython/pull/31691/commits/402dafe63d8a11a6916d549ada1918ce962a8653
5cc3ab2 Stop using `self._flavour` in `as_uri()`. barneygale Jul 30, 2022 https://github.com/python/cpython/pull/31691/commits/5cc3ab2eb9a49ad2dfc1bb764cdc02c524b92951
19a8804 Remove `cls._flavour` identity check in `_parse_parts()`. barneygale Jul 30, 2022 https://github.com/python/cpython/pull/31691/commits/19a88045cf9c9bbde393d209fd93e88160bc53c4
9da46bc Fix Windows tests barneygale Jul 30, 2022 https://github.com/python/cpython/pull/31691/commits/9da46bc3a874b90ac9d7b6581d5e1ff9481fbc9b
29f9f81 Restore `_split_root()` method and its tests. barneygale Aug 1, 2022 https://github.com/python/cpython/pull/31691/commits/29f9f8120779587f1a9fa2c40cbd3e52cb66ad63
52851b8 Merge branch 'main' into bpo-44136-remove-pathlib-flavour-2 barneygale Aug 5, 2022 https://github.com/python/cpython/pull/31691/commits/52851b82b4c2e16a699cf19e4e1a9affbab79ae3
b39da53 Optimize `_split_root()` barneygale Aug 12, 2022 https://github.com/python/cpython/pull/31691/commits/b39da536dc355d274e228d7810bbac20d0b70916
c7b18b1 Merge branch 'main' into bpo-44136-remove-pathlib-flavour-2 barneygale Aug 13, 2022 https://github.com/python/cpython/pull/31691/commits/c7b18b19ed99810ef50611d6bd994c260531e7d2
806ad15 Move `is_reserved()` implementation into `os.path` as a private funct… barneygale Aug 23, 2022 https://github.com/python/cpython/pull/31691/commits/806ad150ac5f7397623ea5d0c6869f3b7d43b6a1
a350009 Use `os.path.normcase()` when globbing. barneygale Aug 23, 2022 https://github.com/python/cpython/pull/31691/commits/a35000959fe4f1ae83b8c1bd4369f728c185d92a
799b40e Simplify `_split_root()` implementation. barneygale Aug 25, 2022 https://github.com/python/cpython/pull/31691/commits/799b40ef2ed0aa9479a05e6bd6c0fa1a7b0adda3
a6b25ea Remove tests for malformed UNC paths barneygale Aug 26, 2022 https://github.com/python/cpython/pull/31691/commits/a6b25ea8e0954782e50cd70077daedcf195a8ec4
ac6f6e2 Merge branch 'main' into bpo-44136-remove-pathlib-flavour-2 brettcannon Aug 26, 2022 https://github.com/python/cpython/pull/31691/commits/ac6f6e2d40b30836d76800ffea8483be560c2a55
b8874df Revert "Move `is_reserved()` implementation into `os.path` as a priva… barneygale Aug 27, 2022 https://github.com/python/cpython/pull/31691/commits/b8874dfed181f2be6c331ddf1a4a68a64e396bd6
9d5e18a Tweak _split_root() to use removesuffix() barneygale Aug 27, 2022 https://github.com/python/cpython/pull/31691/commits/9d5e18a3502a8941783dcad0c9f0e4a65ccb68c6
f73f426 Remove test that `/b/c/d` and `///b/c/d` are equivalent. barneygale Aug 27, 2022 https://github.com/python/cpython/pull/31691/commits/f73f426d1eb2625722f1e6a8287c2b495ed6f0bc
37e4bc1 Restore comment linking to *Naming Files* page in Microsoft docs barneygale Sep 16, 2022 https://github.com/python/cpython/pull/31691/commits/37e4bc1e06907b59878c8ae23e6071a58c68b404
e3f13ef Apply suggestions from code review barneygale Nov 7, 2022 https://github.com/python/cpython/pull/31691/commits/e3f13efcbed4241f65fbdc44d4962ef9a7ee3d66
ff4e1b3 Merge branch 'main' into bpo-44136-remove-pathlib-flavour-2 barneygale Nov 15, 2022 https://github.com/python/cpython/pull/31691/commits/ff4e1b362a0d90ba5d11f7fddf26ddb21fdffbc6
07c67d0 Clarify repr roundtrip tests. barneygale Nov 15, 2022 https://github.com/python/cpython/pull/31691/commits/07c67d00f68adf2c160895ba9ec0a32408e2d173
950aa47 Reduce tests diff barneygale Nov 15, 2022 https://github.com/python/cpython/pull/31691/commits/950aa47d638cd1feb50c93f09a10b2ba89f4b2f4
d5f6f03 Remove test that `/b/c/d` and `///b/c/d` are equivalent. barneygale Aug 27, 2022 https://github.com/python/cpython/pull/31691/commits/d5f6f0332acc02f18bcfeffee94cd7eee0f5c4f2
b66a4fb Fix missing full stops. barneygale Nov 15, 2022 https://github.com/python/cpython/pull/31691/commits/b66a4fbf50a05f51e52f3f1c8f2a5a0345c0810e
fbaadf4 Remove four more test assertions affected by #96290 barneygale Nov 15, 2022 https://github.com/python/cpython/pull/31691/commits/fbaadf45d443c33a1df8d1122aee0805de3c7822
3692fdf Merge branch 'main' into bpo-44136-remove-pathlib-flavour-2 barneygale Nov 25, 2022 https://github.com/python/cpython/pull/31691/commits/3692fdf498fba56e46f21a0e3ac89e0821f79bd8
40dc514 Wrap repr test cases in `self.subTest()` block barneygale Dec 17, 2022 https://github.com/python/cpython/pull/31691/commits/40dc5147b6da2c16d42f817d6eec24b30501e24f
Clear filters https://github.com/python/cpython/pull/31691/files
Please reload this pagehttps://github.com/python/cpython/pull/31691/files
Please reload this pagehttps://github.com/python/cpython/pull/31691/files
pathlib.py https://github.com/python/cpython/pull/31691/files#diff-fa525485738fc33d05b06c159172ff1f319c26e88d8c6bb39f7dbaae4dc4105c
test_pathlib.py https://github.com/python/cpython/pull/31691/files#diff-3dd97d2dc8816848d0b0c442e8fdeec9650b3de77935289a93f37ac6396ee17f
2022-03-05-02-14-09.bpo-24132.W6iORO.rst https://github.com/python/cpython/pull/31691/files#diff-91c7091668fd4c037e5f8110c32036f50ed3dc2ad4eb6229e06bebafe7fa7c10
Please reload this pagehttps://github.com/python/cpython/pull/31691/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.