Jeremy Pinto added the comment:
In fact, the issue seems to be coming from open() itself when opening a
non-existent directory in write mode:
[nav] In [1]: import os
...: nonexixstent_dir = 'not_a_dir/'
...: assert not os.path.exists(nonexixstent_dir)
New submission from Jeremy Pinto :
Issue: If you try to copy a file to a directory that doesn't exist using
shutil.copy, a IsADirectory error is raised saying the directory exists.
This issue is actually caused when `open(not_a_dir, 'wb') is called on a
non-existing dir.
Exp