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.

Title: [doc] mention that os.mkdir() raises FileNotFound if path does not exist
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.11, Python 3.10, Python 3.9
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, ebianchi, iritkatriel, miss-islington, r.david.murray, slateny
Priority: normal Keywords: easy, patch

Created on 2017-06-15 14:08 by ebianchi, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 31548 merged slateny, 2022-02-24 07:08
PR 31877 merged miss-islington, 2022-03-14 19:57
PR 31878 merged miss-islington, 2022-03-14 19:57
Messages (5)
msg296097 - (view) Author: Enrico Bianchi (ebianchi) Date: 2017-06-15 14:08
Currently, documentation for os.mkdir() (see ) reports only FileExistsError exception if directory exists. Please, add other exceptions (e.g. FileNotFoundError if directory is created in a non existent path) or report OSError as superclass of exceptions returned from this method
msg296107 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2017-06-15 15:28
We don't generally document all exceptions that a method can raise, only those that are relevant to its specific API.  In this case, documenting the exception answers the question, "what happens if the directory already exists?"  This question is relevant to the API since the other reasonable possibility is that it would act as if the mkdir had succeeded.  As for documenting OSError, I'm sure there are ways to get os.mkdir to raise an exception that is not an OSError.

However, there is an argument to be made for documenting FileNotFound: the other reasonable thing the function could do in that case would be to create all intermediate path parts, but it does not do that (you use os.makedirs for that).  Since os.makedirs is documented right after os.mkdir, I'm not sure it is worth adding, but one can make the argument :)
msg415179 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2022-03-14 19:57
New changeset 879fbd9472753149b627f32add3ddca90ac47ab7 by slateny in branch 'main':
bpo-30677: [doc] mention that os.mkdir() can raise FileNotFoundError (GH-31548)
msg415186 - (view) Author: miss-islington (miss-islington) Date: 2022-03-14 20:51
New changeset efa72501599029d9ac3f8a2e5ce900302c7d8f56 by Miss Islington (bot) in branch '3.10':
[3.10] bpo-30677: [doc] mention that os.mkdir() can raise FileNotFoundError (GH-31548) (GH-31877)
msg415187 - (view) Author: miss-islington (miss-islington) Date: 2022-03-14 20:52
New changeset b4fd91b4d931dd97ceaf76750d227dd042c236f8 by Miss Islington (bot) in branch '3.9':
[3.9] bpo-30677: [doc] mention that os.mkdir() can raise FileNotFoundError (GH-31548) (GH-31878)
Date User Action Args
2022-04-11 14:58:47adminsetgithub: 74862
2022-03-14 20:53:04iritkatrielsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2022-03-14 20:52:16miss-islingtonsetmessages: + msg415187
2022-03-14 20:51:01miss-islingtonsetmessages: + msg415186
2022-03-14 19:57:36miss-islingtonsetpull_requests: + pull_request29975
2022-03-14 19:57:31miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request29974
2022-03-14 19:57:23iritkatrielsetnosy: + iritkatriel
messages: + msg415179
2022-02-24 07:08:32slatenysetkeywords: + patch
nosy: + slateny

pull_requests: + pull_request29669
stage: patch review
2022-01-11 15:24:31iritkatrielsetkeywords: + easy
title: Enhance documentation of os.mkdir() -> [doc] mention that os.mkdir() raises FileNotFound if path does not exist
versions: + Python 3.9, Python 3.10, Python 3.11, - Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7
2017-06-15 15:28:35r.david.murraysetnosy: + r.david.murray
messages: + msg296107
2017-06-15 14:08:58ebianchicreate