-
-
Notifications
You must be signed in to change notification settings - Fork 31k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Possible bad copy paste in glob.py
#129350
Comments
@serhiy-storchaka You created this, is this an error? |
What is the problem here? What do you mean by "bad copy paste"? This code was introduced in 6f20170, |
It was here from the beginning, and it was intentional (the difference is in the trailing slash). Surprisingly, the tests were not failed after your change, because they are too lenient in this question for some reasons. It is better to make the tests more strict so any unintentional changes will be caught. |
Test that the trailing pathname separator is preserved. Multiple trailing pathname separators are only preserved if the pattern does not contain metacharacters, otherwise only one trailing pathname separator is preserved. This is rather an implementation detail.
I thought about this logic, but can we transform: if basename:
if _lexists(_join(root_dir, pathname), dir_fd):
yield pathname
else:
# Patterns ending with a slash should match only directories
if _isdir(_join(root_dir, dirname), dir_fd):
yield pathname
return Into: if _lexists(_join(root_dir, pathname), dir_fd) or _isdir(_join(root_dir, dirname), dir_fd):
yield pathname
return |
No, that would match nonexistent files (and remove a helpful comment). |
I think it is bad copy paste here
cpython/Lib/glob.py
Line 74 in 7ec1742
Maybe we should
yield dirname
?Additional information
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Reporter: Burkov Egor (eburkov@rvision.ru).
Organization: R-Vision (support@rvision.ru).
Linked PRs
The text was updated successfully, but these errors were encountered: