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.

Author chrahunt
Recipients chrahunt
Date 2019-07-29.04:22:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1564374136.89.0.594392746042.issue37700@roundup.psfhosted.org>
In-reply-to
Content
Currently shutil.copyfile only raises SpecialFileError for named pipes. When trying to use the function to copy a socket file, the exception raised depends on the platform, for example:

macOS: "[Errno 102] Operation not supported on socket: '/Users/guido/src/mypy/dmypy.sock'"
HP-UX: "[Errno 223] Operation not supported: 'example/foo'"
Solaris: "[Errno 122] Operation not supported on transport endpoint: 'example/foo'"
AIX: "[Errno 64] Operation not supported on socket: '../../example/foo'"
Linux: "[Errno 6] No such device or address: 'example/foo'"

This can be reproduced like:

    import os
    import shutil
    import socket
    import tempfile

    d = tempfile.mkdtemp()
    src = os.path.join(d, "src")
    dest = os.path.join(d, "dest")
    sock = socket.socket(socket.AF_UNIX)
    sock.bind(src)

    shutil.copyfile(src, dest)

Making shutil.copyfile raise SpecialFileError for socket files would improve the interface of this function since the same class of error could be ignored. This is mostly useful with shutil.copytree, which defaults to copyfile for its copy function.
History
Date User Action Args
2019-07-29 04:22:16chrahuntsetrecipients: + chrahunt
2019-07-29 04:22:16chrahuntsetmessageid: <1564374136.89.0.594392746042.issue37700@roundup.psfhosted.org>
2019-07-29 04:22:16chrahuntlinkissue37700 messages
2019-07-29 04:22:16chrahuntcreate