Do not use percent format in strings by radarhere · Pull Request #8045 · python-pillow/Pillow
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| msg = ( | |
| "bad or missing Length in stream dict " | |
| f"({result.get(b'Length')})" | |
| ) | |
| stream_len = result.get(b"Length") | |
| msg = f"bad or missing Length in stream dict ({stream_len})" |
radarhere#25 feels that error message should fit onto one line. The change above this would be my suggestion for that goal.
The suggestion from the PR is
stream_len_str = result.get(b"Length") try: stream_len = int(stream_len_str) except (TypeError, KeyError, ValueError) as e: msg = f"bad or missing Length in stream dict ({stream_len_str})" raise PdfFormatError(msg) from e
I think that makes the code harder to read, because, if you ignore the exception, there's more to understand.