[issue28564] shutil.rmtree is inefficient due to listdir() instead of scandir()

Serhiy Storchaka report at bugs.python.org
Wed Oct 25 12:25:02 EDT 2017


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

Following Antoine's suggestion the patch now makes shutil.rmtree() using os.scandir() on all platforms.

I doubt about one thing. This patch changes os.listdir passed to the onerror handler to os.scandir. This can break a user code that checks if the first argument in onerror is os.listdir. If keep this change, it should be documented in the "Porting to 3.7" section. Alternatively, we can continue passing os.listdir if os.scandir() failed despites the fact that os.listdir no longer used.

----------
nosy: +pitrou

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue28564>
_______________________________________


More information about the Python-bugs-list mailing list