Skip to content

Commit

Permalink
fix: prevent overwriting of the warnings by PyPDF2 (#20170)
Browse files Browse the repository at this point in the history
* fix: prevent overwriting of the warings by PyPDF2

PyPDF2 overwrites the warning function which causes a follow-up problem where warnings can not be displayed

* fix: prevent overwriting of the warings by PyPDF2

PyPDF2 overwrites the warning function which causes a follow-up problem where warnings can not be displayed
  • Loading branch information
jll-02 committed Feb 28, 2023
1 parent ea78695 commit dca7c38
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion frappe/tests/test_pdf.py
Expand Up @@ -46,7 +46,7 @@ def test_read_options_from_html(self):
def test_pdf_encryption(self):
password = "qwe"
pdf = pdfgen.get_pdf(self.html, options={"password": password})
reader = PdfFileReader(io.BytesIO(pdf))
reader = PdfFileReader(io.BytesIO(pdf), overwriteWarnings=False)
self.assertTrue(reader.isEncrypted)
if six.PY2:
password = frappe.safe_encode(password)
Expand Down
2 changes: 1 addition & 1 deletion frappe/utils/pdf.py
Expand Up @@ -42,7 +42,7 @@ def get_pdf(html, options=None, output=None):

# https://pythonhosted.org/PyPDF2/PdfFileReader.html
# create in-memory binary streams from filedata and create a PdfFileReader object
reader = PdfFileReader(io.BytesIO(filedata))
reader = PdfFileReader(io.BytesIO(filedata), overwriteWarnings=False)
except OSError as e:
if any([error in str(e) for error in PDF_CONTENT_ERRORS]):
if not filedata:
Expand Down

0 comments on commit dca7c38

Please sign in to comment.