[issue38906] copy2 doesn't copy metadata on Windows and MacOS

Giampaolo Rodola' report at bugs.python.org
Wed Nov 27 05:57:27 EST 2019


Giampaolo Rodola' <g.rodola at gmail.com> added the comment:

If we use CopyFileExW in copy2(), then also copystat() and copymode() should be able to copy the same metadata/security-bits/etc as CopyFileExW. I don't know which Windows APIs should be used though.

I sort of agree with Steven that CopyFileExW could be used everywhere (meaning copyfile()), but that basically means breaking backward compatibility re. what is promised in the doc, and am not sure how to deal with that. For that reason it's probably it's better to leave copyfile() alone. 

On macOS it seems we can use fcopyfile(3) syscall (which is already exposed) and its flag argument (COPYFILE_METADATA, COPYFILE_DATA. COPYFILE_XATTR, etc,) to implement both copy2() and copystat() / copymode().

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38906>
_______________________________________


More information about the Python-bugs-list mailing list