classification
Title: shutil.copystat should (allow to) copy ownership, and other attributes
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: noctiflore
Priority: normal Keywords:

Created on 2017-04-11 15:42 by noctiflore, last changed 2017-04-14 17:59 by serhiy.storchaka.

Messages (1)
msg291499 - (view) Author: Florent Coriat (noctiflore) Date: 2017-04-11 15:42
shutil.copystat() copies permissions, timestamps and even flags and xattrs (if supported), but not ownership.
Furthermore, shutil.copy2() documentation until 2.7 used to say it behaves like cp -p, which preserves ownership, and not xattr nor flags. (On my system it silently fails to copy ownership when not root).

It may not be related, but comments in source code for the except NotImplementedError block concerning chmod mistakenly mentions chown-related functions.

I think copystat (and copy2) should at least provide an option to preserve ownership.
I do not know if it currently preserves SELinux context and ACL, but if not, it may also allow it.
It would be really useful for replication or backup applications to have a function that copies everything it can.
History
Date User Action Args
2017-04-14 17:59:26serhiy.storchakasetversions: - Python 3.5, Python 3.6
2017-04-11 15:42:33noctiflorecreate