Skip to content

gh-157617: Add overwrite parameter to Path.symlink_to() - #157659

Open
tonyyuyiding wants to merge 1 commit into
python:mainfrom
tonyyuyiding:fix-gh-157617
Open

tonyyuyiding wants to merge 1 commit into
python:mainfrom
tonyyuyiding:fix-gh-157617

Conversation

@tonyyuyiding

@tonyyuyiding tonyyuyiding commented Sep 17, 2026

Copy link
Copy Markdown

Add an overwrite parameter to Path.symlink_to.

Previously, FileExistsError was raised if the path already exists. With this new overwrite parameter, users now have the option to overwrite the existing path with the new symlink. The parameter is added to the end of the signature and defaults to False to ensure backward compatibility.

The name overwrite was chosen instead of exist_ok because it indicates that the operation is potentially harmful. This also makes it explicit that the existing path is not overwritten by default.

Tests, docs and news have been updated accordingly.

@python-cla-bot

python-cla-bot Bot commented Sep 17, 2026

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #34605548 | 📁 Comparing 3c9e388 against main (c39a329)

  🔍 Preview build  

2 files changed
± library/pathlib.html
± whatsnew/changelog.html

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.

1 participant