mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 21:51:50 +00:00 
			
		
		
		
	bpo-29623: Make PathLike objects work with ConfigParser.read() (#242)
This commit is contained in:
		
							parent
							
								
									677ab995ce
								
							
						
					
					
						commit
						85b8d01c91
					
				
					 4 changed files with 31 additions and 8 deletions
				
			
		|  | @ -143,6 +143,7 @@ | |||
| import functools | ||||
| import io | ||||
| import itertools | ||||
| import os | ||||
| import re | ||||
| import sys | ||||
| import warnings | ||||
|  | @ -687,7 +688,7 @@ def read(self, filenames, encoding=None): | |||
| 
 | ||||
|         Return list of successfully read files. | ||||
|         """ | ||||
|         if isinstance(filenames, str): | ||||
|         if isinstance(filenames, (str, os.PathLike)): | ||||
|             filenames = [filenames] | ||||
|         read_ok = [] | ||||
|         for filename in filenames: | ||||
|  | @ -696,6 +697,8 @@ def read(self, filenames, encoding=None): | |||
|                     self._read(fp, filename) | ||||
|             except OSError: | ||||
|                 continue | ||||
|             if isinstance(filename, os.PathLike): | ||||
|                 filename = os.fspath(filename) | ||||
|             read_ok.append(filename) | ||||
|         return read_ok | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 David Ellis
						David Ellis