mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 09:14:27 +03:00
Catch OSError when checking if fp is sys.stdout
This commit is contained in:
parent
9b4fff85b3
commit
c712d68df2
|
@ -493,7 +493,11 @@ def _save(im, fp, tile, bufsize=0):
|
||||||
# But, it would need at least the image size in most cases. RawEncode is
|
# But, it would need at least the image size in most cases. RawEncode is
|
||||||
# a tricky case.
|
# a tricky case.
|
||||||
bufsize = max(MAXBLOCK, bufsize, im.size[0] * 4) # see RawEncode.c
|
bufsize = max(MAXBLOCK, bufsize, im.size[0] * 4) # see RawEncode.c
|
||||||
if fp == sys.stdout or (hasattr(sys.stdout, "buffer") and fp == sys.stdout.buffer):
|
try:
|
||||||
|
stdout = fp == sys.stdout or fp == sys.stdout.buffer
|
||||||
|
except (OSError, AttributeError):
|
||||||
|
stdout = False
|
||||||
|
if stdout:
|
||||||
fp.flush()
|
fp.flush()
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user