-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-132322: Ensure shutil functions return str when using pathlib #132820
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
base: main
Are you sure you want to change the base?
gh-132322: Ensure shutil functions return str when using pathlib #132820
Conversation
Fixes issue python#132322 by normalizing return types in shutil.copy, copy2, copyfile, copytree, and move using os.fspath(), so that they consistently return str even when pathlib.Path is passed. All relevant tests pass locally
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind adding a test?
@@ -0,0 +1 @@ | ||
shutil.copy, copy2, copyfile, copytree, and move now consistently return str even when passed pathlib.Path arguments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use Sphinx refs:
shutil.copy, copy2, copyfile, copytree, and move now consistently return str even when passed pathlib.Path arguments. | |
:func:`shutil.copy`, :func:`~shutil.copy2`, :func:`~shutil.copyfile`, :func:`~shutil.copytree`, and :func:`~shutil.move` now consistently return :class:`str` even when passed :class:`pathlib.Path` arguments. |
Fixes issue #132322 by normalizing return types in shutil.copy, copy2, copyfile, copytree, and move using os.fspath(), so that they consistently return str even when pathlib.Path is passed.
All relevant tests pass locally