Repository navigation
Remove pathlib accessors #87178
Description
Activity
Per Pitrou:
The original intent for the “accessor” thing was to have a variant that did all accesses under a filesystem tree in a race condition-free way using openat and friends. It turned out to be much too hairy to actually implement, so was entirely abandoned, but the accessor abstraction was left there.
https://discuss.python.org/t/make-pathlib-extensible/3428/2
Accessors are:
- Lacking any internal purpose - '_NormalAccessor' is the only implementation
- Lacking any firm conceptual difference to
Pathobjects themselves (inc. subclasses) - Non-public, i.e. underscore prefixed - '_Accessor' and '_NormalAccessor'
- Unofficially used to implement customized
Pathobjects, but once once bpo-24132 lands there will be a supported route for that.
When bpo-24132 lands, I think we're free to remove accessors and simplify some code
- addedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
on Jan 23, 2021 - added3.11only security fixesonly security fixesperformancePerformance or resource usagePerformance or resource usage
on May 14, 2021 PR looks good, just needs a look by a pathlib expert.
Thank you Éric!
This change is actually causing a problem for me. I have a unit test case which mocks out os.path.expanduser() but not the pathlib version. This works in 3.10 and earlier due to the indirection of the accessors, but in 3.11 the code ends up failing, since now the pathlib version of expanduser() is also getting into my mock.
I wonder if there might be other code out there which also might be depending on this behavior, without even realizing it.
pathlib._Accessor#25701Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields: