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
shutil.chown should support dir_fd and follow_symlinks keyword arguments #62308
Note: 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:
assignee=Noneclosed_at=Nonecreated_at=<Date2013-05-31.13:09:57.018>labels= ['easy', 'type-feature', 'library']
title='shutil.chown should support dir_fd and follow_symlinks keyword arguments'updated_at=<Date2019-10-28.20:48:21.699>user='https://github.com/cjwatson'
Python 3.3 added the dir_fd and follow_symlinks keyword arguments to os.chown; it also added the shutil.chown function. Unfortunately the latter, while useful, does not support these new keyword arguments. It would be helpful if it did.
[1/1] test_shutil
test test_shutil failed -- Traceback (most recent call last):
File "/tank/libs/cpython/Lib/test/test_shutil.py", line 1258, in test_chown
shutil.chown(os.path.basename(filename), dir_fd=dirfd)
File "/tank/libs/cpython/Lib/shutil.py", line 983, in chownraiseValueError("user and/or group must be set")
ValueError: user and/or group must be set
It seems that either user or group argument must be passed along with dir_fd.
avinassh commented on Jun 29, 2019
avinasshmannequin
Mannequin
More actions
I was looking for an easy patch to submit. I can take an attempt at this?
tahia-khan commented on Sep 9, 2019
tahia-khanmannequin
Mannequin
More actions
Hi everybody,
I just submitted a PR for this issue. It's my first contribution to the cPython project so please let me know if I need to change anything.
Activity
cjwatson commentedon May 31, 2013
Python 3.3 added the dir_fd and follow_symlinks keyword arguments to os.chown; it also added the shutil.chown function. Unfortunately the latter, while useful, does not support these new keyword arguments. It would be helpful if it did.
PCManticore commentedon Jun 13, 2014
Hi. Would you like to provide a patch?
berkerpeksag commentedon Jun 14, 2014
Here's a patch.
PCManticore commentedon Jun 14, 2014
Looks good to me. But aren't the last two lines skipped if an error is raised by the first line from the with block?
+ with self.assertRaises(FileNotFoundError):
+ shutil.chown('invalid-file', user=uid, dir_fd=dirfd)
+ shutil.chown('invalid-file', group=gid, dir_fd=dirfd)
+ shutil.chown('invalid-file', user=uid, group=gid, dir_fd=dirfd)
PCManticore commentedon Jun 27, 2014
I got a failure on FreeBSD:
It seems that either user or group argument must be passed along with dir_fd.
avinassh commentedon Jun 29, 2019
I was looking for an easy patch to submit. I can take an attempt at this?
tahia-khan commentedon Sep 9, 2019
Hi everybody,
I just submitted a PR for this issue. It's my first contribution to the cPython project so please let me know if I need to change anything.