New submission from Mher Movsisyan <mher.movsis...@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.
Lib/os.py: 136 def makedirs(name, mode=0777): 137 """makedirs(path [, mode=0777]) 138 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. 143 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 <rep...@bugs.python.org> <http://bugs.python.org/issue5586> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com