mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-12 10:16:17 +03:00
Merge pull request #4296 from radarhere/unlink
Ensure tempfile is unlinked
This commit is contained in:
commit
cd006ce3c8
|
@ -616,6 +616,7 @@ def _save_netpbm(im, fp, filename):
|
||||||
# below for information on how to enable this.
|
# below for information on how to enable this.
|
||||||
tempfile = im._dump()
|
tempfile = im._dump()
|
||||||
|
|
||||||
|
try:
|
||||||
with open(filename, "wb") as f:
|
with open(filename, "wb") as f:
|
||||||
if im.mode != "RGB":
|
if im.mode != "RGB":
|
||||||
subprocess.check_call(
|
subprocess.check_call(
|
||||||
|
@ -630,7 +631,10 @@ def _save_netpbm(im, fp, filename):
|
||||||
quant_cmd, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL
|
quant_cmd, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL
|
||||||
)
|
)
|
||||||
togif_proc = subprocess.Popen(
|
togif_proc = subprocess.Popen(
|
||||||
togif_cmd, stdin=quant_proc.stdout, stdout=f, stderr=subprocess.DEVNULL
|
togif_cmd,
|
||||||
|
stdin=quant_proc.stdout,
|
||||||
|
stdout=f,
|
||||||
|
stderr=subprocess.DEVNULL,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Allow ppmquant to receive SIGPIPE if ppmtogif exits
|
# Allow ppmquant to receive SIGPIPE if ppmtogif exits
|
||||||
|
@ -643,7 +647,7 @@ def _save_netpbm(im, fp, filename):
|
||||||
retcode = togif_proc.wait()
|
retcode = togif_proc.wait()
|
||||||
if retcode:
|
if retcode:
|
||||||
raise subprocess.CalledProcessError(retcode, togif_cmd)
|
raise subprocess.CalledProcessError(retcode, togif_cmd)
|
||||||
|
finally:
|
||||||
try:
|
try:
|
||||||
os.unlink(tempfile)
|
os.unlink(tempfile)
|
||||||
except OSError:
|
except OSError:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user