Issue #23076: Path.glob() now raises a ValueError if it's called with an

invalid pattern.

Patch by Thomas Nyberg.
This commit is contained in:
Berker Peksag 2016-01-30 17:50:48 +02:00
parent ef410770a7
commit 4a208e448e
4 changed files with 11 additions and 0 deletions

View file

@ -1065,6 +1065,8 @@ class Path(PurePath):
"""Iterate over this subtree and yield all existing files (of any
kind, including directories) matching the given pattern.
"""
if not pattern:
raise ValueError("Unacceptable pattern: {!r}".format(pattern))
pattern = self._flavour.casefold(pattern)
drv, root, pattern_parts = self._flavour.parse_parts((pattern,))
if drv or root: