[issue41560] pathlib.Path.glob fails on empty string

Pablo Galindo Salgado report at bugs.python.org
Mon Aug 17 19:39:18 EDT 2020


Pablo Galindo Salgado <pablogsal at gmail.com> added the comment:

> This is not the desired or expected behaviour, which would be to just return `path` if it exists. 

That's the expected behaviour if the call is successful (it does not violate any pre-condition.

> This behaviour is also inconsistent with the documentation which states

Not IMHO, what the documentation is described is the happy path/successful call. If the pattern is invalid, it can perfectly raise and error and the documentation will still be true.

> And it is in contrast to the behaviour of glob.glob, which is just fine with the empty string, returning an empty list.

This is the point that is interesting to discuss. Why is this behavior desirable? In my view, it can be the source of bugs if the user is not aware that what is placing there is an empty string. When is useful to pass something that can be an empty string?+

----------
nosy: +pablogsal

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41560>
_______________________________________


More information about the Python-bugs-list mailing list