Merge pull request #3580 from jdufresne/bytes-warning

Fix 'BytesWarning: Comparison between bytes and string' in PdfDict
This commit is contained in:
Hugo 2019-02-27 23:38:45 +02:00 committed by GitHub
commit df6d429789
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -269,18 +269,13 @@ class PdfDict(UserDict):
else:
self.__dict__[key] = value
else:
if isinstance(key, str):
key = key.encode("us-ascii")
self[key] = value
self[key.encode("us-ascii")] = value
def __getattr__(self, key):
try:
value = self[key]
value = self[key.encode("us-ascii")]
except KeyError:
try:
value = self[key.encode("us-ascii")]
except KeyError:
raise AttributeError(key)
raise AttributeError(key)
if isinstance(value, bytes):
value = decode_text(value)
if key.endswith("Date"):