mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 21:51:50 +00:00 
			
		
		
		
	Issue #20331: Fixed possible FD leaks in various modules:
http.server, imghdr, mailcap, mimetypes, xml.etree.
This commit is contained in:
		
						commit
						c0b0bb6e01
					
				
					 5 changed files with 34 additions and 30 deletions
				
			
		|  | @ -7,18 +7,16 @@ | |||
| #-------------------------# | ||||
| 
 | ||||
| def what(file, h=None): | ||||
|     if h is None: | ||||
|         if isinstance(file, str): | ||||
|             f = open(file, 'rb') | ||||
|             h = f.read(32) | ||||
|         else: | ||||
|             location = file.tell() | ||||
|             h = file.read(32) | ||||
|             file.seek(location) | ||||
|             f = None | ||||
|     else: | ||||
|         f = None | ||||
|     f = None | ||||
|     try: | ||||
|         if h is None: | ||||
|             if isinstance(file, str): | ||||
|                 f = open(file, 'rb') | ||||
|                 h = f.read(32) | ||||
|             else: | ||||
|                 location = file.tell() | ||||
|                 h = file.read(32) | ||||
|                 file.seek(location) | ||||
|         for tf in tests: | ||||
|             res = tf(h, f) | ||||
|             if res: | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Serhiy Storchaka
						Serhiy Storchaka