New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pathlib.Path.owner() and .group() should accept a follow_symlinks argument
#103363
Labels
Comments
|
Sounds reasonable to me! |
|
@markrwilliams are you working on this issue? I'd be happy to add it if you are not. |
|
Given no action for several months on this issue, I decided to open a PR. |
kamilturek
added a commit
to kamilturek/cpython
that referenced
this issue
Dec 2, 2023
barneygale
pushed a commit
that referenced
this issue
Dec 4, 2023
|
Implemented by @kamilturek in #107962, merged into 3.13 as a1551b4 🎉 |
aisk
pushed a commit
to aisk/cpython
that referenced
this issue
Feb 11, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels


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
Most
pathlib.Pathmethods 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
stattolstat, which was deemed too disruptive.#18864 added
follow_symlinkstopathlib.Path.statandpathlib.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.
Linked PRs
pathlib.Path.owner()andgroup()#107962The text was updated successfully, but these errors were encountered: