mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-10-31 07:57:27 +03:00 
			
		
		
		
	Do not seek if the file pointer is about to be closed
This commit is contained in:
		
							parent
							
								
									b7ad0d8852
								
							
						
					
					
						commit
						f9236a11ce
					
				|  | @ -1165,6 +1165,7 @@ class TiffImageFile(ImageFile.ImageFile): | ||||||
|         except ValueError: |         except ValueError: | ||||||
|             raise IOError("Couldn't set the image") |             raise IOError("Couldn't set the image") | ||||||
| 
 | 
 | ||||||
|  |         close_self_fp = self._exclusive_fp and not self._is_animated | ||||||
|         if hasattr(self.fp, "getvalue"): |         if hasattr(self.fp, "getvalue"): | ||||||
|             # We've got a stringio like thing passed in. Yay for all in memory. |             # We've got a stringio like thing passed in. Yay for all in memory. | ||||||
|             # The decoder needs the entire file in one shot, so there's not |             # The decoder needs the entire file in one shot, so there's not | ||||||
|  | @ -1182,6 +1183,7 @@ class TiffImageFile(ImageFile.ImageFile): | ||||||
|             # we've got a actual file on disk, pass in the fp. |             # we've got a actual file on disk, pass in the fp. | ||||||
|             if DEBUG: |             if DEBUG: | ||||||
|                 print("have fileno, calling fileno version of the decoder.") |                 print("have fileno, calling fileno version of the decoder.") | ||||||
|  |             if not close_self_fp: | ||||||
|                 self.fp.seek(0) |                 self.fp.seek(0) | ||||||
|             # 4 bytes, otherwise the trace might error out |             # 4 bytes, otherwise the trace might error out | ||||||
|             n, err = decoder.decode(b"fpfp") |             n, err = decoder.decode(b"fpfp") | ||||||
|  | @ -1199,7 +1201,7 @@ class TiffImageFile(ImageFile.ImageFile): | ||||||
|         self.load_end() |         self.load_end() | ||||||
| 
 | 
 | ||||||
|         # libtiff closed the fp in a, we need to close self.fp, if possible |         # libtiff closed the fp in a, we need to close self.fp, if possible | ||||||
|         if self._exclusive_fp and not self._is_animated: |         if close_self_fp: | ||||||
|             self.fp.close() |             self.fp.close() | ||||||
|             self.fp = None  # might be shared |             self.fp = None  # might be shared | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user