[New-bugs-announce] [issue5586] The documentation of os.makedirs is misleading

Mher Movsisyan report at bugs.python.org
Sat Mar 28 15:16:32 CET 2009

New submission from Mher Movsisyan <mher.movsisyan at gmail.com>:

The documentation of os.makedirs (http://docs.python.org/library/os.html?
highlight=makedirs#os.makedirs) is misleading. It states that os.makedirs raises an 
exception if the leaf directory already exists but it doesn't.


136 def makedirs(name, mode=0777):
137     """makedirs(path [, mode=0777])
139     Super-mkdir; create a leaf directory and all intermediate ones.
140     Works like mkdir, except that any intermediate path segment (not
141     just the rightmost) will be created if it does not exist.  This is
142     recursive.
144     """
145     head, tail = path.split(name)
146     if not tail:
147         head, tail = path.split(head)
148     if head and tail and not path.exists(head):
149         try:
150             makedirs(head, mode)
151         except OSError, e:
152             # be happy if someone already created the path
153             if e.errno != errno.EEXIST:
154                 raise
155         if tail == curdir:           # xxx/newdir/. exists if xxx/newdir exists
156             return
157     mkdir(name, mode)

The attachment is a patch of the documentation (trunk, revision 70643).

assignee: georg.brandl
components: Documentation
files: makedirs.diff
keywords: patch
messages: 84305
nosy: georg.brandl, mher
severity: normal
status: open
title: The documentation of os.makedirs is misleading
versions: Python 2.6, Python 3.0
Added file: http://bugs.python.org/file13439/makedirs.diff

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list