From 524addc4993e2d653f86bbaadce3d29a6b3d6d81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dvo=C5=99=C3=A1k=20V=C3=A1clav?= Date: Fri, 26 Jan 2018 15:32:54 +0100 Subject: [PATCH] issue #2959: argh, do we really need to support Python 2.x? ;-) --- src/PIL/pdfParser.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/PIL/pdfParser.py b/src/PIL/pdfParser.py index 6b3162bf0..aa0f2b38a 100644 --- a/src/PIL/pdfParser.py +++ b/src/PIL/pdfParser.py @@ -239,7 +239,10 @@ class PdfDict(UserDict): try: value = self[key] except KeyError: - value = self[key.encode("us-ascii")] + try: + value = self[key.encode("us-ascii")] + except KeyError: + raise AttributeError(key) if isinstance(value, bytes): return decode_text(value) else: