-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Description
Feature or enhancement
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.