[issue36422] tempfile.TemporaryDirectory() removes entire directory tree even if it's a mount-point

Giampaolo Rodola' report at bugs.python.org
Sat Jun 29 07:57:21 EDT 2019


Giampaolo Rodola' <g.rodola at gmail.com> added the comment:

> in case a filesystem has been mounted on the temporary directory, this can lead to the entire filesystem being removed

-1

That is expected behavior and the use case looks pretty unusual. Such a new parameter wouldn't even be supported by other "batteries" since there's no portable/standard way to either mount or unmount a directory (in fact you had to use a subprocess in your unit-tests).

A `delete=bool` parameter would be a more reasonable proposal in principle but:
1) if you want to keep the directory around then you can just use tempfile.mkdtemp() (see "there should preferably be only one way to do it")
2) it would conflict with the context manager usage which is expected to delete the dir on ctx manager exit

In summary, I think this would over-complicate the API for no good reason. 
I'm closing this out as rejected.

----------
resolution:  -> rejected
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.9 -Python 3.6

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


More information about the Python-bugs-list mailing list