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 plakhotich
Recipients plakhotich
Date 2015-11-08.14:34:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Since Windows 7 (or even Vista), Windows gives permission error(5, ERROR_ACCESS_DENIED
if you try to create a directory in a drive root with the same name as a drive itself,
even if you have administrative permissions. This behavior is not mentioned in Microsoft docs.

Here is an example session (Windows 7, admin):
d:\>IF EXIST . echo True
d:\>mkdir .
Access is denied.
d:\>mkdir dir
d:\>cd dir
d:\dir>mkdir .
A subdirectory or file . already exists.
d:\dir>cd ..
d:\>py -3
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (In
tel)] on win32
>>> import os
>>> os.path.isdir('.')
>>> os.makedirs('.', exist_ok=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python34\lib\", line 237, in makedirs
    mkdir(name, mode)
PermissionError: [WinError 5] ...
>>> try:
...   os.mkdir('.')
... except OSError as e:
...   print(e.errno)

This means that if you want to write portable code, you still need to write like in Python 2:
    if not os.path.isdir(path):
Which makes exist_ok useless.

The actual problem is in this line (Lib/
    if not exist_ok or e.errno != errno.EEXIST or not path.isdir(name):

Due the reasons described above, makedirs shouldn't rely on e.errno, so the right code will be:
    if not (exist_ok and path.isdir(name)):

I think the issue is pretty serious to be backported.
Date User Action Args
2015-11-08 14:34:33plakhotichsetrecipients: + plakhotich
2015-11-08 14:34:33plakhotichsetmessageid: <>
2015-11-08 14:34:33plakhotichlinkissue25583 messages
2015-11-08 14:34:33plakhotichcreate