[New-bugs-announce] [issue43165] Support the same files with new param in shutil.copyfile

Milan Balazs report at bugs.python.org
Mon Feb 8 12:32:01 EST 2021


New submission from Milan Balazs <milanbalazs01 at gmail.com>:

The "shutil.copyfile" raises a "SameFileError" exception if the src and dts files are the same.

There is no option to allow the same files(like in case of shutil.copytree(dirs_exist_ok=False)).

For example:

import shutil

shutil.copyfile("test.txt", "test.txt")

Output:

>>> python3 test.py 
Traceback (most recent call last):
  File "test.py", line 3, in <module>
    shutil.copyfile("test.txt", "test.txt")
  File "/usr/lib/python3.6/shutil.py", line 104, in copyfile
    raise SameFileError("{!r} and {!r} are the same file".format(src, dst))
shutil.SameFileError: 'test.txt' and 'test.txt' are the same file

----------
components: Library (Lib)
messages: 386634
nosy: milanbalazs
priority: normal
severity: normal
status: open
title: Support the same files with new param in shutil.copyfile
type: enhancement
versions: Python 3.10

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


More information about the New-bugs-announce mailing list