-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
23.7.x find commands permission error #13086
23.7.x find commands permission error #13086
Conversation
try: | ||
for entry in os.scandir(dir_path): | ||
m = pat.match(entry.name) | ||
if m and entry.is_file(): | ||
res.add(m.group(1)) | ||
except PermissionError: | ||
except (FileNotFoundError, 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.
A call to os.scandir('conda.py')
produces NotADirectoryError
which is a subclass of OsError
. Should be added to this except: clause.
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 tested this locally:
$ python -c "import os; os.scandir('yellow')"
Traceback (most recent call last):
File "<string>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'yellow'
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.
Add an existing file to PATH.
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.
ugh
Description
While we check whether a path is a directory we don't also check whether the user has read access resulting in PermissionError if any paths are restricted.
Resolves #13058
Target
23.7.x
instead ofmain
, supersedes #13062Checklist - did you ...
news
directory (using the template) for the next release's release notes?Add / update outdated documentation?