New submission from Alexander Heger <alex.he...@gmail.com>:

Passing an empty string to pathlib.Path.glob fails.

Example
```
from pathlib import Path
path = Path('./myfile.txt')
path.glob('')
```

The result is:
```
~/Python/lib/python3.8/pathlib.py in glob(self, pattern)
   1129         """
   1130         if not pattern:
-> 1131             raise ValueError("Unacceptable pattern: 
{!r}".format(pattern))
   1132         drv, root, pattern_parts = self._flavour.parse_parts((pattern,))
   1133         if drv or root:

ValueError: Unacceptable pattern: ''
```

This is not the desired or expected behaviour, which would be to just return 
`path` if it exists.  This behaviour is also inconsistent with the 
documentation which states (Python 3.8.5):
"""
Glob the given relative pattern in the directory represented by this path, 
yielding all matching files (of any kind):
"""

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

----------
components: Library (Lib)
messages: 375499
nosy: alex.heger
priority: normal
severity: normal
status: open
title: pathlib.Path.glob fails on empty string
type: crash
versions: Python 3.8

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue41560>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to