-
-
Notifications
You must be signed in to change notification settings - Fork 31.2k
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
Pathlib.rename isn't robust #90475
Comments
Pathlib.rename will fail across file system with: OSError: [Errno 18] Invalid cross-device link e.g: This is because it uses os.rename under the hood: One can either replace it with Before submitting a patch for that, I would like to get feedback for that. |
Sounds good. Would you expose the |
@Barney, I am not sure that I understand your question. I think adding another method class _NormalAccessor(_Accessor):
...
self.move = shutil.move
class Path:
....
def move(self, src, dest):
self._accessor.move(self, target)
return self.__class__(target) Now, this is hardly a patch. I need to submit a PR with proper docs, tests and NEWS entry... I will be glad to work on it. However, I guess I need someone to "sponsor" it and merge it. |
shutil.move() accepts a shutil.move(src, dst, copy_function=copy2) It's possible to set |
Thanks for the answer, it makes sense now. Yes, I would adopt this. |
Fair enough. Users who wanted to avoid copying file metadata would then do something like this, I suppose? import pathlib
import shutil
path = pathlib.Path('foo')
path.move('bar', copy_function=shutil.copy) I guess the downside here is that users would still need to |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: