Message361259
It appears that the pathlib library strips out `.` in glob paths when they represent a directory. This is kind of a naive approach in my opinion, but I understand what was trying to be achieved.
When a path is given to pathlib, it normalizes it by stripping out non-essential things like `.` that represent directories, and strips out trailing `/` to give a path without unnecessary parts (the stripping of trailing `/` is another discussion).
But there is a small twist, when given an empty string or just a dot, you need to have something as the directory, so it allows a `.`.
So, it appears the idea was since this normalization is applied to paths, why not apply it to the glob patterns as well, so it does. But the special logic that ensures you don't have an empty string to match does not get applied to the glob patterns. This creates unmatchable paths:
>>> import pathlib
>>> str(pathlib.Path('.'))
'.'
>>> pathlib.Path('.').match('.')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python36\lib\pathlib.py", line 939, in match
raise ValueError("empty pattern")
ValueError: empty pattern
I wonder if it is appropriate to apply this `.` stripping to glob patterns. Personally, I think the glob pattern, except for slash normalization, should remain unchanged, but if it is to be normalized above and beyond this, at the very least should use the exact same logic that is applied to the paths. |
|
Date |
User |
Action |
Args |
2020-02-02 23:45:17 | Isaac Muse | set | recipients:
+ Isaac Muse |
2020-02-02 23:45:17 | Isaac Muse | set | messageid: <1580687117.16.0.54415875836.issue39532@roundup.psfhosted.org> |
2020-02-02 23:45:17 | Isaac Muse | link | issue39532 messages |
2020-02-02 23:45:16 | Isaac Muse | create | |
|