Closed MatthiasValvekens closed 8 months ago
All modified and coverable lines are covered by tests :white_check_mark:
Comparison is base (
ddf26f8
) 98.81% compared to head (9578947
) 98.82%.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
LGTM -- I can confirm that encrypt_dict is now accessible as a class property 🎉
If you want, you could probably dump _get_encryption_params()
and expose encrypt_dict directly using the property decorator like so: https://github.com/MatthiasValvekens/pyHanko/pull/346/files#diff-b31a4a5713e1dec7776e9bdc1372e73085050e9d9f7061a26d37586eb403afc5R207-R208 (seems to test fine locally, but unsure if this will have other unintended effects)
Yeah, fair enough. Yesterday me thought we might as well preserve the _get_encryption_params
method while adding the property, but on reflection I agree it's kind of pointless.
Description of the changes
Clean up some of the init logic in
PdfFileReader
(without fundamentally changing the fact that the xref table is processed during__init__
), and in particular, for encrypted files, we now defer loading of the security handler to a later point. As a side effect, this means that problems with the security handler will be raised during object access and/or calls to.encrypt()/.decrypt()
rather than during__init__
, which is hopefully a bit more user-friendly. It also exposes the encryption dictionary as a property on thePdfFileReader
class. Closes #332.Caveats
Technically, the removal of the
.read()
method onPdfFileReader
is a breaking change. Practically, it's not, since calling that method out of order would already have broken all sorts of things anyway.Checklist
Please go over this checklist to increase the chances of your PR being worked on in a timely manner. Deviations are allowed with proper justification (see previous section).
For new features (delete if not applicable)