Skip to content

[3.15] gh-109503: Fix document for shutil.move() on usage of os.rename() since it's inaccurate (GH-109507)#150611

Merged
serhiy-storchaka merged 1 commit into
python:3.15from
miss-islington:backport-6ecd197-3.15
Jun 9, 2026
Merged

[3.15] gh-109503: Fix document for shutil.move() on usage of os.rename() since it's inaccurate (GH-109507)#150611
serhiy-storchaka merged 1 commit into
python:3.15from
miss-islington:backport-6ecd197-3.15

Conversation

@miss-islington

@miss-islington miss-islington commented May 30, 2026

Copy link
Copy Markdown
Contributor

Nonatomic move might be used even if the files are
on the same filesystem in some cases.
(cherry picked from commit 6ecd197)

Co-authored-by: Fang Li fangli@users.noreply.github.com

…() since it's inaccurate (pythonGH-109507)

Nonatomic move might be used even if the files are
on the same filesystem in some cases.
(cherry picked from commit 6ecd197)

Co-authored-by: Fang Li <fangli@users.noreply.github.com>
@miss-islington miss-islington requested a review from giampaolo as a code owner May 30, 2026 14:26
@python-cla-bot

python-cla-bot Bot commented May 30, 2026

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@StanFromIreland

Copy link
Copy Markdown
Member

@fangli can you please sign the CLA again (see bot comment above), you can read more about why this is necessary in the devguide.

@fangli

fangli commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Signed CLA again, you may proceed. @StanFromIreland thanks for following up.

Comment thread Doc/library/shutil.rst
of *src* will be created as the destination and *src* will be removed.
:func:`os.rename` is preferably used internally when *src* and the destination are on
the same filesystem. In case :func:`os.rename` fails due to :exc:`OSError`
(e.g. the user has write permission to the destination file but not to its parent

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Avoid Latin abbreviations: https://devguide.python.org/documentation/style-guide/#use-simple-language

Suggested change
(e.g. the user has write permission to the destination file but not to its parent
(for example, the user has write permission to the destination file but not to its parent

Comment thread Lib/shutil.py
recreated under the new name if os.rename() fails because of cross
filesystem renames.
os.rename() is preferably used if the source and destination are on the
same filesystem. In case os.rename() fails due to OSError (e.g. the user

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
same filesystem. In case os.rename() fails due to OSError (e.g. the user
same filesystem. In case os.rename() fails due to OSError (for example, the user

@serhiy-storchaka

Copy link
Copy Markdown
Member

@hugovk, this is a backport PR. Sure we want to keep it consistent with main.

@hugovk

hugovk commented Jun 9, 2026

Copy link
Copy Markdown
Member

Okay, let's also fix main and can then fix the backports too.

@serhiy-storchaka serhiy-storchaka merged commit 19e4b8f into python:3.15 Jun 9, 2026
102 of 104 checks passed
@miss-islington miss-islington deleted the backport-6ecd197-3.15 branch June 9, 2026 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants