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 milanbalazs
Recipients milanbalazs
Date 2021-02-08.17:32:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1612805521.88.0.931585192254.issue43165@roundup.psfhosted.org>
In-reply-to
Content
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
History
Date User Action Args
2021-02-08 17:32:01milanbalazssetrecipients: + milanbalazs
2021-02-08 17:32:01milanbalazssetmessageid: <1612805521.88.0.931585192254.issue43165@roundup.psfhosted.org>
2021-02-08 17:32:01milanbalazslinkissue43165 messages
2021-02-08 17:32:01milanbalazscreate