[New-bugs-announce] [issue37701] shutil.copyfile raises SpecialFileError for symlink to fifo

Christopher Hunt report at bugs.python.org
Mon Jul 29 00:36:51 EDT 2019


New submission from Christopher Hunt <chrahunt at gmail.com>:

Currently shutil.copyfile raises SpecialFileError when src is a link to a fifo. To reproduce:

    import os
    import shutil
    import tempfile
    
    
    d = tempfile.mkdtemp()
    fifo = os.path.join(d, 'fifo')
    link_to_fifo = os.path.join(d, 'link-to-fifo')
    copy_of_link_to_fifo = os.path.join(d, 'copy-of-link-to-fifo')
    
    
    os.mkfifo(fifo)
    os.symlink(fifo, link_to_fifo)
    shutil.copyfile(link_to_fifo, copy_of_link_to_fifo)

Example output:

    Traceback (most recent call last):
      File "repro.py", line 14, in <module>
        shutil.copyfile(link_to_fifo, copy_of_link_to_fifo)
      File "/home/chris/.pyenv/versions/3.7.2/lib/python3.7/shutil.py", line 115, in copyfile
        raise SpecialFileError("`%s` is a named pipe" % fn)
    shutil.SpecialFileError: `/tmp/user/1000/tmpxhigll5g/link-to-fifo` is a named pipe

I would have expected this to copy the symlink without complaint. Raising a SpecialFileError would be OK if `follow_symlinks` was False.

----------
components: Library (Lib)
messages: 348597
nosy: chrahunt
priority: normal
severity: normal
status: open
title: shutil.copyfile raises SpecialFileError for symlink to fifo
type: behavior
versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7, Python 3.8

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


More information about the New-bugs-announce mailing list