Title: shutil: Inconsistent return types when using pathlib · Issue #132322 · python/cpython · GitHub
Open Graph Title: shutil: Inconsistent return types when using pathlib · Issue #132322 · python/cpython
X Title: shutil: Inconsistent return types when using pathlib · Issue #132322 · python/cpython
Description: Bug report Bug description: Using pathlib with shutil usually works, but there are some quirks when it comes to return types. As an example, see the copy function (but other functions are affected as well): cpython/Lib/shutil.py Lines 46...
Open Graph Description: Bug report Bug description: Using pathlib with shutil usually works, but there are some quirks when it comes to return types. As an example, see the copy function (but other functions are affected ...
X Description: Bug report Bug description: Using pathlib with shutil usually works, but there are some quirks when it comes to return types. As an example, see the copy function (but other functions are affected ...
Opengraph URL: https://github.com/python/cpython/issues/132322
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"shutil: Inconsistent return types when using pathlib","articleBody":"# Bug report\n\n### Bug description:\n\nUsing `pathlib` with `shutil` usually works, but there are some quirks when it comes to return types. As an example, see the `copy` function (but other functions are affected as well):\n\nhttps://github.com/python/cpython/blob/67ded6a4faae29edff8e4f7886978e71ce116e33/Lib/shutil.py#L468-L484\n\nIn this case, if a `Path` object gets passed in as `dst`, it will be returned unchanged if it is not a directory, but a `str` will be returned if it is a directory. That's unexpected, the return type should be consistent, probably by always returning a `str`.\n\nI assume that pathlib support is mostly incidental in shutil, considering that the latter predates the former. shutil should probably be reviewed for proper pathlib support at some point. (See also a few other pathlib/shutil related issues reported here.)\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\n_No response_\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-132820\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/srittau","@type":"Person","name":"srittau"},"datePublished":"2025-04-09T15:33:00Z","url":"https://github.com/python/cpython/issues/132322"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:dac5d517-9d4e-dd49-2968-799481e1d835 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 981E:33DDEF:267D3E9:34D5A7A:6B004CAA |
| html-safe-nonce | c2dbfda1a191d7608ef27f74f2039e303e3099814ca20c78f6f613c48dd810df |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5ODFFOjMzRERFRjoyNjdEM0U5OjM0RDVBN0E6NkIwMDRDQUEiLCJ2aXNpdG9yX2lkIjoiNzAzOTgwNDk3MDIzNjkyMzA1MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 262f2d889250ebb1c071f73dcf5227674e31cb583740236fc80eacf9bcc45feb |
| hovercard-subject-tag | issue:2983190354 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/132322/issue_layout |
| twitter:image | https://opengraph.githubassets.com/36d397c1ad407ecccae3572f2c795da8546a87218340543fe283fac2c2d11db4/python/cpython/issues/132322 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/36d397c1ad407ecccae3572f2c795da8546a87218340543fe283fac2c2d11db4/python/cpython/issues/132322 |
| og:image:alt | Bug report Bug description: Using pathlib with shutil usually works, but there are some quirks when it comes to return types. As an example, see the copy function (but other functions are affected ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | srittau |
| hostname | github.com |
| expected-hostname | github.com |
| None | f9517bf360d46638a1e5e7daee7158842fe5ef43c9000afa0e127564a7c2f39b |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b27c5dde30676028abd5c5fc53ce5c9b625f8281 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width