mirror of
				https://github.com/python/cpython.git
				synced 2025-10-30 21:21:22 +00:00 
			
		
		
		
	GH-127381: pathlib ABCs: remove case_sensitive argument (#131024)
				
					
				
			Remove the *case_sensitive* argument from `_JoinablePath.full_match()` and `_ReadablePath.glob()`. Using a non-native case sensitivity forces the use of "case-pedantic" globbing, where we `iterdir()` even for non-wildcard pattern segments. But it's hard to know when to enable this mode, as case-sensitivity can vary by directory, so `_PathParser.normcase()` doesn't always give the full picture. The `Path.glob()` implementation is forced to make an educated guess, but we can avoid the issue in the ABCs by dropping the *case_sensitive* argument. (I probably shouldn't have added these arguments in `PurePath` and `Path` in the first place!) Also drop support for `_ReadablePath.glob(recurse_symlinks=False)`, which makes recursive globbing much slower.
This commit is contained in:
		
							parent
							
								
									c3487c941d
								
							
						
					
					
						commit
						93fc3d34f9
					
				
					 4 changed files with 27 additions and 30 deletions
				
			
		|  | @ -709,18 +709,6 @@ def test_glob_empty_pattern(self): | |||
|         p = P(self.base) | ||||
|         self.assertEqual(list(p.glob("")), [p.joinpath("")]) | ||||
| 
 | ||||
|     def test_glob_case_sensitive(self): | ||||
|         P = self.cls | ||||
|         def _check(path, pattern, case_sensitive, expected): | ||||
|             actual = {str(q) for q in path.glob(pattern, case_sensitive=case_sensitive)} | ||||
|             expected = {str(P(self.base, q)) for q in expected} | ||||
|             self.assertEqual(actual, expected) | ||||
|         path = P(self.base) | ||||
|         _check(path, "DIRB/FILE*", True, []) | ||||
|         _check(path, "DIRB/FILE*", False, ["dirB/fileB"]) | ||||
|         _check(path, "dirb/file*", True, []) | ||||
|         _check(path, "dirb/file*", False, ["dirB/fileB"]) | ||||
| 
 | ||||
|     def test_info_exists(self): | ||||
|         p = self.cls(self.base) | ||||
|         self.assertTrue(p.info.exists()) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Barney Gale
						Barney Gale