Winson Luk added the comment:
To replicate:
$ mkdir foo
$ sudo chown root foo
$ sudo touch foo/child
$ python3
>>> import shutil
>>> shutil.move('foo', 'bar')
PermissionError
$ ls foo
child
$ ls bar
child
If shutil.move() encountered a permission error
New submission from Winson Luk :
shutil.move calls shutil.copytree(), then os.rmtree() (in that order). If the
user does not have permission to delete the source directory, copytree succeeds
but rmtree fails. The user sees an error (Permission Denied), but the
destination directory is still
Change by Winson Luk :
--
keywords: +patch
pull_requests: +22843
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/24001
___
Python tracker
<https://bugs.python.org/issu
Change by Winson Luk :
--
components: Library (Lib)
nosy: winsonluk
priority: normal
severity: normal
status: open
title: shutil.move creates a new directory even on failure
type: behavior
versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9