You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
shutil.copyfile raises SpecialFileError for symlink to fifo #81882
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.
Raising a SpecialFileError would be OK if follow_symlinks was False.
I expect it to fail if follow_symlinks is True, which is the default value. I expect it to succeed with follow_symlinks=False, which should create a shallow copy of just the symlink, regardless of its target. Instead, what happens is that it calls shutil._stat(fn) on both src and dst, regardless of follow_symlinks. I think the call should be shutil._stat(fn, follow_symlinks). This requires updating shutil._stat() to pass the value to fn.stat() and os.stat().
chrahunt commented on Dec 15, 2021
chrahuntmannequin
MannequinAuthor
More actions
I expect it to fail if follow_symlinks is True, which is the default value. I expect it to succeed with follow_symlinks=False, which should create a shallow copy of just the symlink, regardless of its target.
Activity
chrahunt commentedon Jul 29, 2019
Currently shutil.copyfile raises SpecialFileError when src is a link to a fifo. To reproduce:
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 pipeI would have expected this to copy the symlink without complaint. Raising a SpecialFileError would be OK if
follow_symlinkswas False.chrahunt commentedon Jul 29, 2019
Likewise when the destination is a symlink - though in that case the value of
follow_symlinksshould probably not matter.eryksun commentedon Dec 11, 2021
I expect it to fail if follow_symlinks is True, which is the default value. I expect it to succeed with follow_symlinks=False, which should create a shallow copy of just the symlink, regardless of its target. Instead, what happens is that it calls shutil._stat(fn) on both src and dst, regardless of follow_symlinks. I think the call should be shutil._stat(fn, follow_symlinks). This requires updating shutil._stat() to pass the value to fn.stat() and os.stat().
chrahunt commentedon Dec 15, 2021
I agree, thanks for the correction.