8000 documentation and behavior do not match for suppressing (PDF) metadata · Issue #17936 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
documentation and behavior do not match for suppressing (PDF) metadata #17936
Closed
@tacaswell

Description

@tacaswell

Bug report

Bug summary

We document that if you pass metadata=None through to the PdfPages we will not emit the auto-generated creator / producer / date metadata (https://matplotlib.org/3.3.0/api/backend_pdf_api.html#matplotlib.backends.backend_pdf.PdfPages) the code does not actually support this:

Code for reproduction

import matplotlib.pyplot as plt
from io import BytesIO
buf = BytesIO()
plt.gcf().savefig(buf, metadata=None, format='pdf')
buf.seek(0)
assert b'Matplotlib' not in buf.getvalue()

Actual outcome

----> 1 assert b'Matplotlib' not in buf.getvalue()

AssertionError: 

Labeling this as a good first issue as there is no API design or controversy here (the code does not do what it is documented to do and I do not think it is controversial to have a way to fully suppress the generation of meta-adat).

The fix is likely spread across Figure.savefig, FigureCanvasPdf.print_pdf, and the PdfPages class. I suspect we need to change of the default values to a sentinal (rather than None), but not sure exactly where. This should be straight forward and contained to one module, but not an issue to learn Python on.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Difficulty: Easyhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuesGood first issueOpen a pull request against these issues if there are no active ones!backend: pdf

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0