classification
Title: shutil.chown should support dir_fd and follow_symlinks keyword arguments
Type: enhancement Stage: patch review
Components: Library (Lib) Versions: Python 3.5
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Claudiu.Popa, berker.peksag, cjwatson, hynek
Priority: normal Keywords: easy, patch

Created on 2013-05-31 13:09 by cjwatson, last changed 2014-06-27 06:08 by Claudiu.Popa.

Files
File name Uploaded Description Edit
issue18108.diff berker.peksag, 2014-06-14 15:13 review
Messages (5)
msg190404 - (view) Author: Colin Watson (cjwatson) * Date: 2013-05-31 13:09
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.
msg220430 - (view) Author: Claudiu Popa (Claudiu.Popa) * (Python triager) Date: 2014-06-13 11:12
Hi. Would you like to provide a patch?
msg220564 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2014-06-14 15:13
Here's a patch.
msg220565 - (view) Author: Claudiu Popa (Claudiu.Popa) * (Python triager) Date: 2014-06-14 15:16
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)
msg221675 - (view) Author: Claudiu Popa (Claudiu.Popa) * (Python triager) Date: 2014-06-27 06:08
I got a failure on FreeBSD:

[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 chown
    raise ValueError("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.
History
Date User Action Args
2014-06-27 06:08:14Claudiu.Popasetmessages: + msg221675
2014-06-14 15:16:38Claudiu.Popasetmessages: + msg220565
2014-06-14 15:13:35berker.peksagsetfiles: + issue18108.diff

nosy: + berker.peksag
messages: + msg220564

keywords: + patch
stage: needs patch -> patch review
2014-06-13 11:12:33Claudiu.Popasettype: enhancement
versions: + Python 3.5, - Python 3.4
keywords: + easy
nosy: + Claudiu.Popa

messages: + msg220430
stage: needs patch
2013-05-31 16:28:16hyneksetnosy: + hynek

versions: + Python 3.4, - Python 3.3
2013-05-31 13:09:57cjwatsoncreate