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 cedricvanrompay
Recipients cedricvanrompay
Date 2018-11-12.12:19:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1542025151.44.0.788709270274.issue35216@psf.upfronthosting.co.za>
In-reply-to
Content
When calling `shutil.copy('file.txt', 'not_here/')`,
if directory `not_here/` does not exist,
the raised error is:

    IsADirectoryError: [Errno 21] Is a directory: 'not_here/'

If the intent of the user was to copy a file in a directory
but the user forgot to create the destination directory,
this can be very misleading,
as the error tends to indicate that the directory exists.

It happened to me and I was thinking
"yes it's a directory, then what?
that's exactly what I want,copy to this directory!"
when the problem was that I forgot to create the destination directory.

I would suggest to catch the `IsADirectoryError`
in shutil.copyfile() (at `open(dst, 'wb')`)
and raise instead an error saying something like
"destination is a directory AND this directory does not exists".
History
Date User Action Args
2018-11-12 12:19:11cedricvanrompaysetrecipients: + cedricvanrompay
2018-11-12 12:19:11cedricvanrompaysetmessageid: <1542025151.44.0.788709270274.issue35216@psf.upfronthosting.co.za>
2018-11-12 12:19:11cedricvanrompaylinkissue35216 messages
2018-11-12 12:19:11cedricvanrompaycreate