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

2019-06-29 Thread Giampaolo Rodola'
Giampaolo Rodola' 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

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

2019-06-21 Thread Jeffrey Kintscher
Change by Jeffrey Kintscher : -- keywords: +patch pull_requests: +14117 stage: -> patch review pull_request: https://github.com/python/cpython/pull/14292 ___ Python tracker

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

2019-06-20 Thread Jeffrey Kintscher
Jeffrey Kintscher added the comment: I implemented an onerror callback for tempfile.TemporaryDirectory() and confirmed that it cannot be used to unmount a mount point. Attempting to unmount the mount point from within the callback results in a resource busy error. It may be related to

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

2019-06-12 Thread Jeffrey Kintscher
Change by Jeffrey Kintscher : -- nosy: +giampaolo.rodola, tarek ___ Python tracker ___ ___ Python-bugs-list mailing list

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

2019-06-10 Thread Jeffrey Kintscher
Jeffrey Kintscher added the comment: tempfile.TemporaryDirectory() relies upon shutil.rmtree() to do the actual cleanup. Up through 3.7, it simply calls shutil.rmtree(). 3.8 adds some more logic using the onerror callback parameter of shutil.rmtree() to try changing the permissions on

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

2019-06-07 Thread Jeffrey Kintscher
Jeffrey Kintscher added the comment: Another data point: On macOS 10.14.4, unlink() returns EBUSY when it tries to delete the mount point. tempfile.TemporaryDirectory() doesn't handle EBUSY and ends up skipping over the mount point and propagates the OSError exception up to the caller. It

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

2019-06-06 Thread Jeffrey Kintscher
Jeffrey Kintscher added the comment: Since having tempfile.TemporaryDirectory() automatically unmount mount points is difficult to implement in a portable way (Windows, BSD/macOS, and Linux are all different), a shorter-term solution could be to add an 'onerror' callback function as a class

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

2019-06-05 Thread Jeffrey Kintscher
Jeffrey Kintscher added the comment: Since tempfile.TemporaryDirectory() already returns some exceptions to the caller when it can't figure out how to delete a directory item, I don't see a problem with throwing PermissionError when encountering a mount point. This would preserve the 'rm

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

2019-06-05 Thread Jeffrey Kintscher
Jeffrey Kintscher added the comment: (correcting typos) What would be the appropriate behavior when unmount_func() fails (e.g. for a permission error)? Right now, any exceptions other than IsADirectoryError, PermissionError, and FileNotFoundError are passed on to the caller. --

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

2019-06-05 Thread Jeffrey Kintscher
Jeffrey Kintscher added the comment: Only deleting from the local filesystem seems reasonable to me. In the context of a temporary directory tree, I don't see a semantic difference between "unmounting a mount point" and "removing a subdirectory entry" -- i.e. they both remove the offending

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

2019-05-22 Thread Jeffrey Kintscher
Change by Jeffrey Kintscher : -- nosy: +websurfer5 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

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

2019-03-25 Thread Riccardo Murri
Riccardo Murri added the comment: > you should be handling errors properly in the first place, > e.g. by changing your mount_sshfs manager to: > > @contextmanager > def mount_sshfs(localdir, remote): > subprocess.run(f"sshfs {remote} {localdir}") > try: >

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

2019-03-25 Thread Josh Rosenberg
Josh Rosenberg added the comment: Allowing delete_on_error=False is kind of defeating the purpose here; the whole point of the with statement is guaranteed, consistent cleanup in both normal and error cases. If you knew enough to know you needed to pass delete_on_error, you'd also know

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

2019-03-25 Thread Riccardo Murri
New submission from Riccardo Murri : The behavior of `tempfile.TemporaryDirectory()` is to delete the temporary directory when done; this behavior cannot be turned off (there's no `delete=False`like `NamedTemporaryFile` has instead). However, in case a filesystem has been mounted on the