This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Isaac Muse
Recipients Isaac Muse
Date 2020-02-02.23:45:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1580687117.16.0.54415875836.issue39532@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-02-02 23:45:17Isaac Musesetrecipients: + Isaac Muse
2020-02-02 23:45:17Isaac Musesetmessageid: <1580687117.16.0.54415875836.issue39532@roundup.psfhosted.org>
2020-02-02 23:45:17Isaac Muselinkissue39532 messages
2020-02-02 23:45:16Isaac Musecreate