fix: prevent overwriting of the warnings by PyPDF2 #20169
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When creating an Object of the class
PDFFileReader
from the package PyPDF2 the global warning function will be overwritten. This definitely happens in version 13, since it uses PyPDF2 in version 1.26.0 where it is done by the standard.This causes problems e.g. in unit tests when warnings are being thrown since some part of the handling in the PDFFileReader warning is incompatible with other warnings and causes an error.
However, there is a simple solution to this because the constructor of the PDFFileReader accepts an argument to skip the overwriting of the warnings.
This problem is also known to PyPDF2 and also fixed in version 2 of PyPDF. Since frappe version 13 uses version 1.26.0 of PyPDF2 it is necessary to adapt to this problem.
For more information on PyPDF2 site check the following issue in their repository: py-pdf/pypdf#67
In this issue there is also stated that the argument for the constructor is the correct and best way to solve this problem.