mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-15 03:46:28 +03:00
Merge pull request #3580 from jdufresne/bytes-warning
Fix 'BytesWarning: Comparison between bytes and string' in PdfDict
This commit is contained in:
commit
df6d429789
|
@ -269,18 +269,13 @@ class PdfDict(UserDict):
|
||||||
else:
|
else:
|
||||||
self.__dict__[key] = value
|
self.__dict__[key] = value
|
||||||
else:
|
else:
|
||||||
if isinstance(key, str):
|
self[key.encode("us-ascii")] = value
|
||||||
key = key.encode("us-ascii")
|
|
||||||
self[key] = value
|
|
||||||
|
|
||||||
def __getattr__(self, key):
|
def __getattr__(self, key):
|
||||||
try:
|
try:
|
||||||
value = self[key]
|
value = self[key.encode("us-ascii")]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
try:
|
raise AttributeError(key)
|
||||||
value = self[key.encode("us-ascii")]
|
|
||||||
except KeyError:
|
|
||||||
raise AttributeError(key)
|
|
||||||
if isinstance(value, bytes):
|
if isinstance(value, bytes):
|
||||||
value = decode_text(value)
|
value = decode_text(value)
|
||||||
if key.endswith("Date"):
|
if key.endswith("Date"):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user