[New-bugs-announce] [issue46317] Pathlib.rename isn't robust
Oz Tiram
report at bugs.python.org
Sun Jan 9 09:52:56 EST 2022
New submission from Oz Tiram <nahumoz at gmail.com>:
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: '/tmp/pipenv-k1m0oynt-yaml/PyYAML-6.0/lib/yaml' -> '/home/oz123/Software/pipenv/pipenv/patched/yaml3'
This is because it uses os.rename under the hood:
https://github.com/python/cpython/blob/3.10/Lib/pathlib.py#L306
One can either replace it with `shutil.move` which works, or one could
add another method to Pathlib.move(...) with similar signature and return value, which calls `shutil.move` under the hood.
Before submitting a patch for that, I would like to get feedback for that.
----------
components: Library (Lib)
messages: 410155
nosy: Oz.Tiram
priority: normal
severity: normal
status: open
title: Pathlib.rename isn't robust
versions: Python 3.10, Python 3.11, Python 3.9
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46317>
_______________________________________
More information about the New-bugs-announce
mailing list