Bug report
Bug description:
I think it's a regression from #142693.
copyfile() rejects a symlink to a device even when follow_symlinks=False.
import os import shutil import tempfile with tempfile.TemporaryDirectory() as directory: src = os.path.join(directory, "src") dst = os.path.join(directory, "dst") os.symlink("/dev/null", src) shutil.copyfile(src, dst, follow_symlinks=False)
- Current behavior:
shutil.SpecialFileError:.../srcis a character device - Expected:
dstis created as a symlink to/dev/null
The docs say:
If
follow_symlinksis false andsrcis a symbolic link, a new symbolic link will be created instead of copying the filesrcpoints to.
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS