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