[issue43165] Support the same files with new param in shutil.copyfile
Milan Balazs added the comment: Could you somebody review the PR for this ticket, please? -- ___ Python tracker <https://bugs.python.org/issue43165> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43165] Support the same files with new param in shutil.copyfile
Milan Balazs added the comment: Sure, you can use try/except but it would be nice if the "shutil.copyfile" function supports the same files. If I have many files (more thousand), I don't want to check them with a try/except. Furthermore if I want to cover the unexpected exceptions as well I need to use nested try/except (I guess it's not the most elegant way). Eg.: try: shutil.copyfile("test.txt", "test.txt") except SameFileError: pass except Exception as unexpected_exception: raise unexpected_exception -- ___ Python tracker <https://bugs.python.org/issue43165> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43165] Support the same files with new param in shutil.copyfile
Change by Milan Balazs : -- keywords: +patch pull_requests: +23274 stage: -> patch review pull_request: https://github.com/python/cpython/pull/24482 ___ Python tracker <https://bugs.python.org/issue43165> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43165] Support the same files with new param in shutil.copyfile
New submission from Milan Balazs : 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 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 <https://bugs.python.org/issue43165> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com