Fix None value of comment

This commit is contained in:
Sergii Tytarenko 2018-08-23 18:51:21 +03:00
parent 693e161855
commit 65b35d84f8

View File

@ -529,7 +529,8 @@ def _write_local_header(fp, im, offset, flags):
o8(0)) o8(0))
if "comment" in im.encoderinfo and \ if "comment" in im.encoderinfo and \
1 <= len(im.encoderinfo["comment"]) <= 255: and im.encoderinfo["comment"] is not None \
and 1 <= len(im.encoderinfo["comment"]) <= 255:
fp.write(b"!" + fp.write(b"!" +
o8(254) + # extension intro o8(254) + # extension intro
o8(len(im.encoderinfo["comment"])) + o8(len(im.encoderinfo["comment"])) +
@ -695,7 +696,8 @@ def _get_global_header(im, info):
for extensionKey in ["transparency", "duration", "loop", "comment"]: for extensionKey in ["transparency", "duration", "loop", "comment"]:
if info and extensionKey in info: if info and extensionKey in info:
if ((extensionKey == "duration" and info[extensionKey] == 0) or if ((extensionKey == "duration" and info[extensionKey] == 0) or
(extensionKey == "comment" and (extensionKey == "comment"
and info[extensionKey] is not None and
not (1 <= len(info[extensionKey]) <= 255))): not (1 <= len(info[extensionKey]) <= 255))):
continue continue
version = b"89a" version = b"89a"