Skip to content

Commit d4a0308

Browse files
pythongh-121509: Document which error os.remove() raises on Windows for files in use
Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit d50c36d)
1 parent f3fd7a9 commit d4a0308

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

‎Doc/library/os.rst‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2740,9 +2740,11 @@ features:
27402740
This function can support :ref:`paths relative to directory descriptors
27412741
<dir_fd>`.
27422742

2743-
On Windows, attempting to remove a file that is in use causes an exception to
2744-
be raised; on Unix, the directory entry is removed but the storage allocated
2745-
to the file is not made available until the original file is no longer in use.
2743+
On Windows, attempting to remove a file that is in use usually raises a
2744+
:exc:`PermissionError`, unless the file was opened with delete access shared,
2745+
for example with :data:`O_TEMPORARY`; on Unix, the directory entry is removed
2746+
but the storage allocated to the file is not made available until the
2747+
original file is no longer in use.
27462748

27472749
This function is semantically identical to :func:`unlink`.
27482750

0 commit comments

Comments
 (0)