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.

classification
Title: shutil copy to non-existant directory
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.6, Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: shutil.copy raises IsADirectoryError when the directory does not actually exist
View: 43219
Assigned To: Nosy List: TheOrangeOne, eryksun
Priority: normal Keywords:

Created on 2015-09-01 11:26 by TheOrangeOne, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg249474 - (view) Author: Jake Howard (TheOrangeOne) Date: 2015-09-01 11:26
If you try and copy a file using shutil.copy to a directory that doesnt exist, it tries to copy the file to the location of the directory, and errors as shutil can't open a directory for 'WB' access, throwing an error, that doesnt reflect the problem.
msg249553 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2015-09-02 15:54
Do you mean the dst path has a trailing slash, but the directory doesn't exist? shutil.copy doesn't check for a trailing slash, so it attempts to open dst as a regular file. On Linux, and probably most POSIX systems, this results in an EISDIR (is a directory) error. On Windows the error is ERROR_INVALID_NAME, which the CRT maps to EINVAL (invalid argument).
History
Date User Action Args
2022-04-11 14:58:20adminsetgithub: 69165
2021-02-24 18:35:02eryksunsetstatus: open -> closed
superseder: shutil.copy raises IsADirectoryError when the directory does not actually exist
resolution: duplicate
stage: resolved
2015-09-02 15:54:56eryksunsetversions: + Python 2.7, Python 3.4, Python 3.5, Python 3.6
nosy: + eryksun

messages: + msg249553

components: + Library (Lib)
2015-09-01 11:26:57TheOrangeOnecreate