-
-
Notifications
You must be signed in to change notification settings - Fork 509
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
Catch 'PermissionError' for unreadable directories #1706
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1706 +/- ##
==========================================
- Coverage 94.55% 94.52% -0.04%
==========================================
Files 79 79
Lines 11754 11760 +6
==========================================
+ Hits 11114 11116 +2
- Misses 640 644 +4
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the patch, I guess it makes sense. If you write a test that's obviously a plus, but I'm fine here without them as well.
jedi/api/project.py
Outdated
try: | ||
if path.joinpath(name).exists(): | ||
return True | ||
except PermissionError: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just open for discussion: Shouldn't we use OSError here? I'm pretty sure that we do not care here if we can read it. If it's not readable, it should probably be ignored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just replaced PermissionError
by OSError
if parent.joinpath(filename).is_file(): | ||
return parent | ||
except PermissionError: | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
I just added some tests |
test/test_inference/test_sys_path.py
Outdated
] | ||
) | ||
def test_get_parent_dir_with_file(path, filename, expected): | ||
assert sys_path._get_parent_dir_with_file(path, filename) == expected |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since os.path.basename(__file__),
might be part of a directory ancestor, we should not test like this. Most of the time this will not be an issue for people, but if it is it's very confusing.
IMO this function is tested well enough with other means and we can probably just omit this test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I removed it
Hi. The master branch of Jedi raises a
PermissionError
on iOS. I added two try excepts on code that assumes a directory is readable. That may be useful on other platforms too. That was the error:/private/var/mobile/Library/Mobile Documents
is the directory where all iCloud Drive files are stored, but it's sandboxed so apps can only read their own container which are located in this directory.Sorry, I don't think iOS is a priority here, but other computers with strict permissions could also raise this error so I think it would be better anyway to handle those cases.