René's URL Explorer Experiment


Title: docs(FileExistsError): improve the documentation when a folder already exists · Issue #162326 · python/cpython · GitHub

Open Graph Title: docs(FileExistsError): improve the documentation when a folder already exists · Issue #162326 · python/cpython

X Title: docs(FileExistsError): improve the documentation when a folder already exists · Issue #162326 · python/cpython

Description: 1. Summary Currently, Python returns the error message “Cannot create a file when that file already exists” when a folder, not solely a file, already exists. If this problem isn’t fixable, it would be nice to add it to the documentation ...

Open Graph Description: 1. Summary Currently, Python returns the error message “Cannot create a file when that file already exists” when a folder, not solely a file, already exists. If this problem isn’t fixable, it would...

X Description: 1. Summary Currently, Python returns the error message “Cannot create a file when that file already exists” when a folder, not solely a file, already exists. If this problem isn’t fixable, it would...

Opengraph URL: https://github.com/python/cpython/issues/162326

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"docs(FileExistsError): improve the documentation when a folder already exists","articleBody":"### 1. Summary\n\nCurrently, Python returns the error message “Cannot create a file when that file already exists” when a folder, not solely a file, already exists.\n\nIf this problem isn’t fixable, it would be nice to add it to the documentation as a known issue to save users’ time.\n\n### 2. MCVE\n\n#### 2.1. Testing environment\n\n1. Windows 11 26H2, Build 26300.9974\n1. Python 3.15.2\n\n#### 2.2. Python REPL\n\n```Python traceback\n>>> from pathlib import Path\n>>> Path(\"kira_goddess_folder\").mkdir()\n>>> Path(\"kira_goddess_folder\").mkdir()\nTraceback (most recent call last):\n  File \"\u003cpython-input-7>\", line 1, in \u003cmodule>\n    Path(\"kira_goddess_folder\").mkdir()\n    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^\n  File \"D:\\Scoop\\apps\\python\\current\\Lib\\pathlib\\__init__.py\", line 1210, in mkdir\n    os.mkdir(self, mode)\n    ~~~~~~~~^^^^^^^^^^^^\nFileExistsError: [WinError 183] Cannot create a file when that file already exists: 'kira_goddess_folder'\n```\n\n#### 2.3. Incorrect error message\n\n[**The `Path.mkdir()` method creates folders, not files**](https://docs.python.org/3/library/pathlib.html#pathlib.Path.mkdir). The “create a **file**” and “**file** already exists” phrases are incorrect in this case.\n\n### 3. Why documentation changes, not fixing the problem?\n\nIt seems to me, the problem isn’t fixable in Python.\n\n1. Python doesn’t use its own error messages for OS exceptions. Error messages [**depend on the system error codes**](https://docs.python.org/3/builtins/exceptions.html#os-exceptions).\n1. The part of the [**comment**](https://github.com/python/cpython/issues/87038#issuecomment-1093897961) on the related issue “Inconsistent exceptions thrown by `pathlib.Path.mkdir` on different OSes”:\n\n\t> In Windows, it's not possible to differentiate the two cases by error code alone, so unfortunately `Path.mkdir()` tries to create the parent path when it contains a non-directory component, and thus a nested `FileExistsError` exception is raised.\n\n1. Windows has [**the error message “Cannot create a file when that file already exists” for the system error code 183**](https://learn.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-#:~:text=ERROR%5FALREADY%5FEXISTS,exists). The error message contains “file”, not “file or folder” or “file or directory”.\n\n### 4. Proposed changes\n\nA note at least such as the one below in [**the section `FileExistsError`**](https://docs.python.org/3/builtins/exceptions.html#FileExistsError) of the Python documentation:\n\n> [!NOTE]\n> On Windows, Python returns the error message “Cannot create a file when that file already exists” if a folder, not solely a file, already exists. This is a known problem that exists because of Windows limitations.\n\n### 5. Best practices of known issues\n\nFor example, see the parts of [**the section “Known issues”**](https://docs.github.com/en/contributing/style-guide-and-content-model/troubleshooting-content-type#known-issues) of the official GitHub Style guide:\n\n> (…) known issues explain problems that people *will* encounter.\n>\n> If a known issue applies to a specific article, document it in that article.\n>\n> The goal of documenting an issue without a workaround is to help people confirm that the issue exists and save them time searching for a solution that doesn't exist yet after GitHub has already determined there isn't a workaround.\n\nFlagging the problem described in this issue as a known issue could save my time and may save time of other Python users in the future.\n\nThanks.\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-162333\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/Kristinita","@type":"Person","name":"Kristinita"},"datePublished":"2026-11-20T13:37:54Z","url":"https://github.com/python/cpython/issues/162326"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:dd8b3077-8f2a-29ce-3fab-9f5891fa1880
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idEB14:2A5566:136617E:19799E7:6B01E945
html-safe-noncee37e8b7a9655c057241bd8a3d9b05e77fea914229a83d2932af43e93aae32f33
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQjE0OjJBNTU2NjoxMzY2MTdFOjE5Nzk5RTc6NkIwMUU5NDUiLCJ2aXNpdG9yX2lkIjoiMTE2OTI4NTQ5Mzk4NjM2ODY5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacb86791b61e6d30cb8d90a02f2dd2c3684cf96e64bb7461e7e8d4d3e973090e60
hovercard-subject-tagissue:6512509338
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/162326/issue_layout
twitter:imagehttps://opengraph.githubassets.com/208c0ba329e64ba09f18639d58a29b8c09073a88d020e9ef248c3125945f04e6/python/cpython/issues/162326
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/208c0ba329e64ba09f18639d58a29b8c09073a88d020e9ef248c3125945f04e6/python/cpython/issues/162326
og:image:alt1. Summary Currently, Python returns the error message “Cannot create a file when that file already exists” when a folder, not solely a file, already exists. If this problem isn’t fixable, it would...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameKristinita
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/162326#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F162326
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F162326
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/162326
Reloadhttps://github.com/python/cpython/issues/162326
Reloadhttps://github.com/python/cpython/issues/162326
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
https://github.com/python/cpython
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/162326
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/162326
#162333https://github.com/python/cpython/pull/162333
docs(FileExistsError): improve the documentation when a folder already existshttps://github.com/python/cpython/issues/162326#top
#162333https://github.com/python/cpython/pull/162333
OS-windowshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22OS-windows%22
docsDocumentation in the Doc dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22docs%22
https://github.com/Kristinita
Kristinitahttps://github.com/Kristinita
on Nov 20, 2026https://github.com/python/cpython/issues/162326#issue-6512509338
The Path.mkdir() method creates folders, not fileshttps://docs.python.org/3/library/pathlib.html#pathlib.Path.mkdir
depend on the system error codeshttps://docs.python.org/3/builtins/exceptions.html#os-exceptions
commenthttps://github.com/python/cpython/issues/87038#issuecomment-1093897961
the error message “Cannot create a file when that file already exists” for the system error code 183https://learn.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-#:~:text=ERROR%5FALREADY%5FEXISTS,exists
the section FileExistsErrorhttps://docs.python.org/3/builtins/exceptions.html#FileExistsError
the section “Known issues”https://docs.github.com/en/contributing/style-guide-and-content-model/troubleshooting-content-type#known-issues
gh-162326: Clarify Windows FileExistsError message for directories #162333https://github.com/python/cpython/pull/162333
NekoAsakurahttps://github.com/NekoAsakura
docsDocumentation in the Doc dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22docs%22
OS-windowshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22OS-windows%22
on Nov 20, 2026https://github.com/python/cpython/issues/162326#event-36774239942
github-project-automationhttps://github.com/apps/github-project-automation
docs issueshttps://github.com/orgs/python/projects/52
on Nov 20, 2026https://github.com/python/cpython/issues/162326#event-36774244867
github-project-automationhttps://github.com/apps/github-project-automation
docs issueshttps://github.com/orgs/python/projects/52
on Nov 20, 2026https://github.com/python/cpython/issues/162326
https://github.com/makwana-akshat
makwana-akshathttps://github.com/makwana-akshat
on Nov 20, 2026https://github.com/python/cpython/issues/162326#issuecomment-7046051247
https://github.com/makwana-akshat
makwana-akshathttps://github.com/makwana-akshat
on Nov 20, 2026https://github.com/python/cpython/issues/162326#issuecomment-7047592444
#162333https://github.com/python/cpython/pull/162333
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/162326
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/162326
OS-windowshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22OS-windows%22
docsDocumentation in the Doc dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22docs%22
docs issueshttps://github.com/orgs/python/projects/52
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.