Skip to content

bpo-28356: Document os.rename() behavior on Windows for differing filesystems #27376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Doc/library/os.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2292,6 +2292,8 @@ features:
will fail with an :exc:`OSError` subclass in a number of cases:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's better to keep this sentence since explicitly stating that all the related exceptions below are subclasses of OSError could be helpful for easily catching the exceptions, but I can remove it nonetheless if wanted here.


On Windows, if *dst* exists a :exc:`FileExistsError` is always raised.
The operation may fail if *src* and *dst* are on different filesystems. Use
:func:`shutil.move` to support moves to a different filesystem.
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe since this statement is Windows-specific, it's fine to keep it under the Windows section despite being slightly unrelated to the general case of dst existing. But let me know if it's preferred to open up a new paragraph above/below (or if removing the sentence on dst exists is preferred).


On Unix, if *src* is a file and *dst* is a directory or vice-versa, an
:exc:`IsADirectoryError` or a :exc:`NotADirectoryError` will be raised
Expand Down