You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pathlib.Path.owner() and .group() should accept a follow_symlinks argument #103363
pathlib.Path.owner() and pathlib.Path.group() always follow symbolic links. They should gain a new argument, follow_symlinks, that defaults to True. This will align their API with that of pathlib.Path.stat() and pathlib.Path.chmod()
Pitch
Most pathlib.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 from stat to lstat, which was deemed too disruptive. #18864 added follow_symlinks to pathlib.Path.stat and pathlib.Path.chmod. A commenter asked about adding this argument to other methods, namely is_file() and is_dir().
I'm happy to contribute the code if this seems worth doing.
Activity
barneygale commentedon Apr 9, 2023
Sounds reasonable to me!
ganesh-k13 commentedon May 14, 2023
@markrwilliams are you working on this issue? I'd be happy to add it if you are not.
kamilturek commentedon Aug 15, 2023
Given no action for several months on this issue, I decided to open a PR.
Merge branch 'main' into pythongh-103363
gh-103363: Add follow_symlinks argument to `pathlib.Path.owner()` and…
barneygale commentedon Dec 4, 2023
Implemented by @kamilturek in #107962, merged into 3.13 as a1551b4 🎉
pythongh-103363: Add follow_symlinks argument to `pathlib.Path.owner(…
jb2170 commentedon Jul 8, 2024
Nice
pythongh-103363: Add follow_symlinks argument to `pathlib.Path.owner(…