mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 09:57:43 +03:00 
			
		
		
		
	Merge pull request #7148 from radarhere/unlink
Remove temporary file when error is raised
This commit is contained in:
		
						commit
						9264c3d29e
					
				| 
						 | 
					@ -134,6 +134,13 @@ def Ghostscript(tile, size, fp, scale=1, transparency=False):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if gs_windows_binary is not None:
 | 
					    if gs_windows_binary is not None:
 | 
				
			||||||
        if not gs_windows_binary:
 | 
					        if not gs_windows_binary:
 | 
				
			||||||
 | 
					            try:
 | 
				
			||||||
 | 
					                os.unlink(outfile)
 | 
				
			||||||
 | 
					                if infile_temp:
 | 
				
			||||||
 | 
					                    os.unlink(infile_temp)
 | 
				
			||||||
 | 
					            except OSError:
 | 
				
			||||||
 | 
					                pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            msg = "Unable to locate Ghostscript on paths"
 | 
					            msg = "Unable to locate Ghostscript on paths"
 | 
				
			||||||
            raise OSError(msg)
 | 
					            raise OSError(msg)
 | 
				
			||||||
        command[0] = gs_windows_binary
 | 
					        command[0] = gs_windows_binary
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -457,6 +457,11 @@ class JpegImageFile(ImageFile.ImageFile):
 | 
				
			||||||
        if os.path.exists(self.filename):
 | 
					        if os.path.exists(self.filename):
 | 
				
			||||||
            subprocess.check_call(["djpeg", "-outfile", path, self.filename])
 | 
					            subprocess.check_call(["djpeg", "-outfile", path, self.filename])
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
 | 
					            try:
 | 
				
			||||||
 | 
					                os.unlink(path)
 | 
				
			||||||
 | 
					            except OSError:
 | 
				
			||||||
 | 
					                pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            msg = "Invalid Filename"
 | 
					            msg = "Invalid Filename"
 | 
				
			||||||
            raise ValueError(msg)
 | 
					            raise ValueError(msg)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user