mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	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:
		
							parent
							
								
									ef410770a7
								
							
						
					
					
						commit
						4a208e448e
					
				
					 4 changed files with 11 additions and 0 deletions
				
			
		|  | @ -1065,6 +1065,8 @@ def glob(self, pattern): | |||
|         """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: | ||||
|  |  | |||
|  | @ -1969,6 +1969,11 @@ def test_unsupported_flavour(self): | |||
|         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): | ||||
|  |  | |||
|  | @ -1038,6 +1038,7 @@ Neal Norwitz | |||
| Mikhail Novikov | ||||
| Michal Nowikowski | ||||
| Steffen Daode Nurpmeso | ||||
| Thomas Nyberg | ||||
| Nigel O'Brian | ||||
| John O'Connor | ||||
| Kevin O'Connor | ||||
|  |  | |||
|  | @ -73,6 +73,9 @@ Library | |||
| - 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 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Berker Peksag
						Berker Peksag