Skip to content

Commit 0276f46

Browse files
committed
atomicreplace
1 parent 3199cfc commit 0276f46

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Doc/library/os.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2774,8 +2774,14 @@ features:
27742774

27752775
.. function:: rename(src, dst, *, src_dir_fd=None, dst_dir_fd=None)
27762776

2777-
Rename the file or directory *src* to *dst*. If *dst* exists, the operation
2778-
will fail with an :exc:`OSError` subclass in a number of cases:
2777+
Rename the file or directory *src* to *dst*. If *dst* exists,
2778+
the operation overwrites it **atomically relative to the
2779+
filesystem namespace** (dst path guaranteed to point to src or not exist
2780+
after the call, per POSIX rename(2)). **Not atomic for content replacement:
2781+
old dst contents may remain briefly accessible on Unix (new dst appears first,
2782+
old unlinked after).** On Windows, dst is silently overwritten if permitted;
2783+
otherwise :exc:`PermissionError` is raised.
2784+
27792785

27802786
On Windows, if *dst* exists a :exc:`FileExistsError` is always raised.
27812787
The operation may fail if *src* and *dst* are on different filesystems. Use

0 commit comments

Comments
 (0)