Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] core: PyPDF2 suppresses warnings #60002

Closed

Conversation

xmo-odoo
Copy link
Collaborator

By default, PdfFileReader will monkeypatch the warnings module even
if it has no reason whatsoever to do so and suppress the
captureWarnings behavior.

This means as soon as we've loaded a PDF file, warnings.warn don't
trigger logging warnings anymore, and become invisible.

This can lead to non-deterministic behaviors depending as warnings may
or may not be suppressed depending when they occur relative to loading
a PDF e.g. load a module which runs a test which loads a PDF before a
module triggering a warning and the warning won't be visible, other
way around it will.

Except ofc while we have an override to PdfFileReader it's not
used everywhere, so need to monkeypatch the init.

By default, PdfFileReader will monkeypatch the `warnings` module even
if it has no reason whatsoever to do so and suppress the
`captureWarnings` behavior.

This means as soon as we've loaded a PDF file, `warnings.warn` don't
trigger `logging` warnings anymore, and become invisible.

This can lead to non-deterministic behaviors depending as warnings may
or may not be suppressed depending when they occur relative to loading
a PDF e.g. load a module which runs a test which loads a PDF before a
module triggering a warning and the warning won't be visible, other
way around it will.

Except ofc while we have an override to PdfFileReader it's not
used *everywhere*, so need to monkeypatch the init.
@xmo-odoo xmo-odoo requested a review from a team as a code owner October 14, 2020 13:36
@C3POdoo C3POdoo added the RD research & development, internal work label Oct 14, 2020
@robodoo robodoo added CI 🤖 Robodoo has seen passing statuses ☑ ci/runbot and removed ☐ ci/runbot labels Oct 14, 2020
@odony
Copy link
Contributor

odony commented Oct 14, 2020

Any chance we could upstream this?

@xmo-odoo
Copy link
Collaborator Author

@odony none, didn't link to the project but pypdf2 has been properly dead for nearly 2 years (py-pdf/pypdf#477) and had limited work before that (the current release dates back to 2016).

There's a discussion on this issue dating back to 2014 (py-pdf/pypdf#67) as well as several PRs to either update or remove this feature but nothing was done even when the project was somewhat actively maintained & updated.

@xmo-odoo
Copy link
Collaborator Author

@robodoo r+

@robodoo robodoo closed this in 6b04dbc Oct 15, 2020
@robodoo robodoo temporarily deployed to merge October 15, 2020 17:35 Inactive
@fw-bot fw-bot deleted the 14.0-fix-stupid-pypdf2-garbage-xmo branch October 29, 2020 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI 🤖 Robodoo has seen passing statuses RD research & development, internal work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants