changeset: 100124:0a6290195f7c parent: 100122:c5fbacf79b1e parent: 100123:35bf4f9e68f3 user: Berker Peksag date: Sat Jan 30 17:51:35 2016 +0200 files: Lib/test/test_pathlib.py Misc/ACKS Misc/NEWS description: Issue #23076: Path.glob() now raises a ValueError if it's called with an invalid pattern. Patch by Thomas Nyberg. diff -r c5fbacf79b1e -r 0a6290195f7c Lib/pathlib.py --- a/Lib/pathlib.py Sat Jan 30 12:34:12 2016 +0200 +++ b/Lib/pathlib.py Sat Jan 30 17:51:35 2016 +0200 @@ -1065,6 +1065,8 @@ """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: diff -r c5fbacf79b1e -r 0a6290195f7c Lib/test/test_pathlib.py --- a/Lib/test/test_pathlib.py Sat Jan 30 12:34:12 2016 +0200 +++ b/Lib/test/test_pathlib.py Sat Jan 30 17:51:35 2016 +0200 @@ -1969,6 +1969,11 @@ else: self.assertRaises(NotImplementedError, pathlib.WindowsPath) + def test_glob_empty_pattern(self): + p = self.cls() + with self.assertRaisesRegex(ValueError, 'Unacceptable pattern'): + list(p.glob('')) + @only_posix class PosixPathTest(_BasePathTest, unittest.TestCase): diff -r c5fbacf79b1e -r 0a6290195f7c Misc/ACKS --- a/Misc/ACKS Sat Jan 30 12:34:12 2016 +0200 +++ b/Misc/ACKS Sat Jan 30 17:51:35 2016 +0200 @@ -1042,6 +1042,7 @@ Mikhail Novikov Michal Nowikowski Steffen Daode Nurpmeso +Thomas Nyberg Nigel O'Brian John O'Connor Kevin O'Connor diff -r c5fbacf79b1e -r 0a6290195f7c Misc/NEWS --- a/Misc/NEWS Sat Jan 30 12:34:12 2016 +0200 +++ b/Misc/NEWS Sat Jan 30 17:51:35 2016 +0200 @@ -166,6 +166,9 @@ - Issue #26202: copy.deepcopy() now correctly copies range() objects with non-atomic attributes. +- Issue #23076: Path.glob() now raises a ValueError if it's called with an + invalid pattern. Patch by Thomas Nyberg. + - Issue #19883: Fixed possible integer overflows in zipimport. - Issue #26227: On Windows, getnameinfo(), gethostbyaddr() and