mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 09:56:17 +03:00
Merge pull request #4683 from cool-RR/2020-06-12-raise-from
Fix exception causes in PdfParser.py
This commit is contained in:
commit
5962c2e797
|
@ -251,8 +251,8 @@ class PdfDict(collections.UserDict):
|
|||
def __getattr__(self, key):
|
||||
try:
|
||||
value = self[key.encode("us-ascii")]
|
||||
except KeyError:
|
||||
raise AttributeError(key)
|
||||
except KeyError as e:
|
||||
raise AttributeError(key) from e
|
||||
if isinstance(value, bytes):
|
||||
value = decode_text(value)
|
||||
if key.endswith("Date"):
|
||||
|
@ -811,11 +811,11 @@ class PdfParser:
|
|||
if m:
|
||||
try:
|
||||
stream_len = int(result[b"Length"])
|
||||
except (TypeError, KeyError, ValueError):
|
||||
except (TypeError, KeyError, ValueError) as e:
|
||||
raise PdfFormatError(
|
||||
"bad or missing Length in stream dict (%r)"
|
||||
% result.get(b"Length", None)
|
||||
)
|
||||
) from e
|
||||
stream_data = data[m.end() : m.end() + stream_len]
|
||||
m = cls.re_stream_end.match(data, m.end() + stream_len)
|
||||
check_format_condition(m, "stream end not found")
|
||||
|
|
Loading…
Reference in New Issue
Block a user