Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Deprecate PdfPages(keep_empty=True). #26469

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

Merged
merged 1 commit into from
Aug 9, 2023
Merged

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Aug 8, 2023

... because 0-page pdfs are not valid pdf files.

Explicitly passing keep_empty=False remains supported for now to help transitioning to the new behavior.

I also delayed file creation in backend_pdf.PdfPages as that seems simpler than re-deleting the file at closure if needed. I further dropped __slots__ as the micro-optimization of these classes seem pointless (backend_pdf.PdfPages is wrapping a PdfFile object which is much larger anyways).

Closes #11771 (see #11771 (comment)). Whether we want #11771 (comment) too is another question.

PR summary

PR checklist

@tacaswell
Copy link
Member

Looking at when this come in: #2453 it was added to add the ability to remove the broken files (rather than a desire to keep broken files) so changing the default seems reasonable to me.

... because 0-page pdfs are not valid pdf files.

Explicitly passing keep_empty=False remains supported for now to help
transitioning to the new behavior.

I also delayed file creation in backend_pdf.PdfPages as that seems
simpler than re-deleting the file at closure if needed.  I further
dropped `__slots__` as the micro-optimization of these classes seem
pointless (backend_pdf.PdfPages is wrapping a PdfFile object which is
much larger anyways).
@tacaswell
Copy link
Member

This still has the problem that using it not as a context manager will fail?

@ksunden ksunden merged commit fb3a97a into matplotlib:main Aug 9, 2023
@anntzer anntzer deleted the dppke branch August 9, 2023 22:20
@ksunden ksunden added this to the v3.8.0 milestone Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change PdfPages to default to keep_empty=False and eventually deprecate keep_empty
3 participants