py-pdf / pypdf

A pure-python PDF library capable of splitting, merging, cropping, and transforming the pages of PDF files
https://pypdf.readthedocs.io/en/latest/
Other
8.12k stars 1.39k forks source link

STY: Use hasattr to determine if an object has an attribute #2718

Closed j-t-1 closed 3 months ago

j-t-1 commented 3 months ago

@stefan6419846 error of my understanding somewhere, I thought the logical and would short circuit.

stefan6419846 commented 3 months ago

You are silently dropping the obj.indirect_reference is None condition with your change, thus most likely leading to the discovered failures.

stefan6419846 commented 3 months ago

I am probably going to close this issue in the next days unless there are explicit reasons to keep it. Using hasattr requires a third condition and there is no real need to refactor this here.