[Python-Dev] Backward compatibility of shutil.rmtree

martin at v.loewis.de martin at v.loewis.de
Sun May 20 23:46:22 CEST 2012


Zitat von Hynek Schlawack <hs at ox.cx>:

>>> Two of them differ in the new version: os.fwalk() is used instead of
>>> os.listdir() and os.unlinkat() instead of os.remove().
>> It would be os.flistdir instead of os.listdir, not os.fwalk, right?
>
> It’s actually os.fwalk. It has been implemented by Charles-François as a
> dependency of the ticket because it seemed generally useful – therefore
> I used it for the implementation.

I think that's a mistake then, because of the limited error reporting.
With os.fwalk, you don't know exactly what it is that failed, but it
may be useful to know.

So I propose to duplicate the walking in rmtree.

I also wonder how exactly in your implementation directory handles
get closed, and how that correlates to attempts at removing the
directories.

> (There has been also been the idea to re-implement the default rmdir
> with os.walk to make them more similar; but that's a different story.)

-1 on that, for the reasons above.

> So you suggest to not mention all the possible functions at all? That
> seems useful to me, as the list will (hopefully) grow anyway and nailing
> it down is getting less useful with every new implementation.

Exactly. Users would have to look at the code, but that will make them
aware that the code may change. For that reason, also, using fwalk is
a bad idea, since they then will need to trace their code reading into
fwalk.

Regards,
Martin





More information about the Python-Dev mailing list