Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle TrashPermissionError, now that it exists #5894

Merged
merged 2 commits into from
Jan 3, 2021

Conversation

stefanor
Copy link
Contributor

@stefanor stefanor commented Dec 1, 2020

In Ubuntu's automated test environment full log example, both HOME and the temporary directories are likely to be on a tmpfs. That will cause
gi.repository.GLib.GError: g-io-error-quark: Trashing on system internal mounts is not supported (15) which will raise a TrashPermissionError.

As the comments in the code indicate, _check_trash() was added (in #3304) because TrashPermissionError didn't
exist, yet. We asked send2trash to implement such an exception, so that we wouldn't have to guess whether a file was trash-able or not, and they did. So, let's take advantage of it.

Because we don't permanently delete, recursively, test_delete_non_empty_dir will now fail in environments where the test data isn't trash-able. So, handle that, and skip the test gracefully.

Closes: #3374

_check_trash() was added (in jupyter#3304) because TrashPermissionError didn't
exist, yet.

Now that it does, we can use it, and stop guessing what will cause a
permission problem.

Closes: jupyter#3374
If the test working directory isn't trashable, we expect to not be able
to delete the non-empty directory.
@stefanor stefanor changed the title Handle TrashPermissionError now that it exists Handle TrashPermissionError, now that it exists Dec 1, 2020
Copy link
Member

@kevin-bates kevin-bates left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice cleanup - thank you.

@kevin-bates kevin-bates merged commit 1672777 into jupyter:master Jan 3, 2021
@stefanor stefanor deleted the trashpermissionerror branch January 6, 2021 01:21
@blink1073 blink1073 added this to the 6.2 milestone Mar 18, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

send2trash.exceptions.TrashPermissionError
3 participants