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 eryksun
Recipients eryksun, jerpint
Date 2021-02-14.06:49:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> IsADirectoryError: [Errno 21] Is a directory: 'not_a_dir/'

The trailing slash forces the OS to handle "not_a_dir" as a directory [1]. 

    A pathname that contains at least one non- <slash> character and that 
    ends with one or more trailing <slash> characters shall not be resolved
    successfully unless the last pathname component before the trailing 
    <slash> characters names an existing directory or a directory entry 
    that is to be created for a directory immediately after the pathname is

Mode "w" corresponds to low-level POSIX open() flags O_CREAT | O_TRUNC | O_WRONLY. If write access is requested for a directory, the open() system call must fail with EISDIR [2].

        The named file is a directory and oflag includes O_WRONLY or O_RDWR,
        or includes O_CREAT without O_DIRECTORY.

In most cases, opening a directory with O_CREAT also fails with E_ISDIR. POSIX does permit an implementation to create a directory with O_CREAT | O_DIRECTORY. In Linux, however, O_CREAT always creates a regular file, regardless of O_DIRECTORY, so open(pathname, O_CREAT | flags) always fails with EISDIR when pathname is an existing directory or names a directory by way of a trailing slash.

Date User Action Args
2021-02-14 06:49:04eryksunsetrecipients: + eryksun, jerpint
2021-02-14 06:49:04eryksunsetmessageid: <>
2021-02-14 06:49:04eryksunlinkissue43219 messages
2021-02-14 06:49:03eryksuncreate