This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: shutil.copy2() copies permission bits
Type: enhancement Stage:
Components: Documentation Versions: Python 3.0, Python 2.4, Python 2.6, Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: belopolsky, georg.brandl, igs
Priority: normal Keywords:

Created on 2008-05-13 21:28 by igs, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg66803 - (view) Author: (igs) Date: 2008-05-13 21:28
At least in Python 2.4 shutil.copy2() not only copies content and 
access times of a files like stated in the documentation but also the 
access bits.

That behaviour I would not expect because in other functions from 
shutil it is explicitly stated if the access bits are copied.

In fact I used
    shutil.copy2(src, dest)
    shutil.copystat(src, dest)
up to now. What does not work if the read-only attribute is set and 
what is completely nonsense after having a look into the implementation.
msg66818 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2008-05-14 14:48
This seems to be a documentation issue.

"""
shutil.copy2(src, dst)
Similar to copy(), but last access time and last modification time are 
copied as well. This is similar to the Unix command cp -p.
""" -- http://docs.python.org/dev/library/shutil.html#shutil.copy2

Does not mention permissions while

"""
$ pydoc shutil.copy2
shutil.copy2 = copy2(src, dst)
    Copy data and all stat info ("cp -p src dst").
"""

implies that the permissions should be copied.

Maybe the documentation should simply recite the implementation: copy2 
is copyfile follwed by copystat.
msg66941 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-05-16 13:19
Thanks, fixed in r63369.
History
Date User Action Args
2022-04-11 14:56:34adminsetgithub: 47094
2008-05-16 13:19:00georg.brandlsetstatus: open -> closed
resolution: fixed
messages: + msg66941
2008-05-14 14:52:08belopolskysetassignee: georg.brandl
type: behavior -> enhancement
nosy: + georg.brandl
components: + Documentation, - Windows
versions: + Python 2.6, Python 2.5, Python 3.0
2008-05-14 14:49:03belopolskysetnosy: + belopolsky
messages: + msg66818
2008-05-13 21:28:49igscreate