Skip to content

Commit

Permalink
Merge pull request #7148 from radarhere/unlink
Browse files Browse the repository at this point in the history
Remove temporary file when error is raised
  • Loading branch information
mergify[bot] committed Jun 6, 2023
2 parents 07be6aa + 3b65261 commit 9264c3d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/PIL/EpsImagePlugin.py
Expand Up @@ -134,6 +134,13 @@ def Ghostscript(tile, size, fp, scale=1, transparency=False):

if gs_windows_binary is not None:
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"
raise OSError(msg)
command[0] = gs_windows_binary
Expand Down
5 changes: 5 additions & 0 deletions src/PIL/JpegImagePlugin.py
Expand Up @@ -457,6 +457,11 @@ def load_djpeg(self):
if os.path.exists(self.filename):
subprocess.check_call(["djpeg", "-outfile", path, self.filename])
else:
try:
os.unlink(path)
except OSError:
pass

msg = "Invalid Filename"
raise ValueError(msg)

Expand Down

0 comments on commit 9264c3d

Please sign in to comment.