[issue46317] Pathlib.rename isn't robust

2022-01-17 Thread Oz Tiram
Change by Oz Tiram : -- keywords: +patch pull_requests: +28851 stage: -> patch review pull_request: https://github.com/python/cpython/pull/30650 ___ Python tracker ___

[issue46317] Pathlib.rename isn't robust

2022-01-15 Thread Barney Gale
Barney Gale added the comment: 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

[issue46317] Pathlib.rename isn't robust

2022-01-15 Thread Oz Tiram
Oz Tiram added the comment: Thanks for the answer, it makes sense now. Yes, I would adopt this. Allowing users to use `copy2` (or any other functio ...) using a keyword. -- ___ Python tracker

[issue46317] Pathlib.rename isn't robust

2022-01-14 Thread Barney Gale
Barney Gale added the comment: shutil.move() accepts a `copy_function` argument: shutil.move(src, dst, copy_function=copy2) It's possible to set `copy_function=copy` to skip copying file metadata. -- ___ Python tracker

[issue46317] Pathlib.rename isn't robust

2022-01-14 Thread Oz Tiram
Oz Tiram added the comment: @barney, I am not sure that I understand your question. I think adding another method `Pathlib.Path` and `Pathlib._Accessor` is my preferred way. The would be something like: class _NormalAccessor(_Accessor): ... self.move = shutil.move

[issue46317] Pathlib.rename isn't robust

2022-01-14 Thread Barney Gale
Barney Gale added the comment: Sounds good. Would you expose the `copy_function` argument in pathlib, or do something else (like `metadata=True`)? -- nosy: +barneygale ___ Python tracker

[issue46317] Pathlib.rename isn't robust

2022-01-09 Thread Oz Tiram
New submission from Oz Tiram : Pathlib.rename will fail across file system with: OSError: [Errno 18] Invalid cross-device link e.g: -> path_dict["current_path"].rename(path_dict["destination"]) (Pdb) n OSError: [Errno 18] Invalid cross-device link: