Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.4k
Description
Feature or enhancement
pathlib.Path.owner()
andpathlib.Path.group()
always follow symbolic links. They should gain a new argument,follow_symlinks
, that defaults toTrue
. This will align their API with that ofpathlib.Path.stat()
andpathlib.Path.chmod()
Pitch
Mostpathlib.Path
methods follow symbolic links, so it's natural for these ownership methods to do the same.
However, doing so unconditionally results in a surprising error when you'd actually like them to look at a link's ownership - for example, to work with a system that uses dangling symbolic links as lock files - and there's no convenient API to call instead.
Previous discussion
#65521 brought up the same issue but proposed fixing it by changing the system call fromstat
tolstat
, which was deemed too disruptive.
#18864 addedfollow_symlinks
topathlib.Path.stat
andpathlib.Path.chmod
.A commenter asked about adding this argument to other methods, namelyis_file()
andis_dir()
.
I'm happy to contribute the code if this seems worth doing.