Skip to content

gh-121509: Clarify that os.remove may raise PermissionError on Windows - #162875

Merged
picnixz merged 1 commit into
python:mainfrom
damijun:fix-gh-121509
Nov 30, 2026
Merged

picnixz merged 1 commit into
python:mainfrom
damijun:fix-gh-121509

Conversation

@damijun

@damijun damijun commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

The docs for os.remove state that on Windows, removing a file that is in
use "causes an exception to be raised". That is too absolute: the call may
succeed, for example for a file opened with os.O_TEMPORARY, which allows
delete sharing. When it does fail, the usual error is PermissionError
(WinError 32).

This corrects the sentence in Doc/library/os.rst to say "may raise
:exc:PermissionError". Documentation-only change; no behaviour is affected,
so no NEWS entry is added.

Verification on Windows 11 / Python 3.15.2:

  • opening the file normally and calling os.remove → PermissionError 32
  • opening with O_CREAT | O_WRONLY | O_TEMPORARY and calling os.remove →
    removal succeeds
  • python -m sphinxlint Doc/library/os.rst → no problems
  • docs HTML build with --fail-on-warning → 0 warnings, 0 errors

The change was prepared with AI assistance and reviewed by me; I can explain
the wording and the platform behaviour in my own words.

Copilot AI balanced review requested due to automatic review settings November 30, 2026 16:02
@python-cla-bot

python-cla-bot Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #36269577 | 📁 Comparing f43d16b against main (f77c71e)

  🔍 Preview build  

1 file changed
± library/os.html

Comment thread Doc/library/os.rst Resolved
@picnixz picnixz added needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Nov 30, 2026
@picnixz
picnixz merged commit 9d6fa5d into python:main Nov 30, 2026
41 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in Docs PRs Nov 30, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @damijun for the PR, and @picnixz for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Nov 30, 2026

Copy link
Copy Markdown

GH-162879 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Nov 30, 2026
@bedevere-app

bedevere-app Bot commented Nov 30, 2026

Copy link
Copy Markdown

GH-162880 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants