10000 pdf: Don't require Trapped to be a Name instance. · matplotlib/matplotlib@31e462b · GitHub
[go: up one dir, main page]

Skip to content

Commit 31e462b

Browse files
committed
pdf: Don't require Trapped to be a Name instance.
It's something internal to the PDF backend, and there's no need to require the metadata to use that type instead of a plain string.
1 parent 1127bbd commit 31e462b

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/matplotlib/backends/backend_pdf.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,11 @@ def is_string_like(x):
187187
def is_date(x):
188188
return isinstance(x, datetime)
189189

190-
check_trapped = (lambda x: isinstance(x, Name) and
191-
x.name in (b'True', b'False', b'Unknown'))
190+
def check_trapped(x):
191+
if isinstance(x, Name):
192+
return x.name in (b'True', b'False', b'Unknown')
193+
else:
194+
return x in ('True', 'False', 'Unknown')
192195

193196
keywords = {
194197
'Title': is_string_like,
@@ -206,6 +209,8 @@ def is_date(x):
206209
cbook._warn_external(f'Unknown infodict keyword: {k}')
207210
elif not keywords[k](info[k]):
208211
cbook._warn_external(f'Bad value for infodict keyword {k}')
212+
if 'Trapped' in info:
213+
info['Trapped'] = Name(info['Trapped'])
209214

210215
return info
211216

lib/matplotlib/tests/test_backend_pgf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ def test_pdf_pages_metadata():
262262
'Subject': 'Test page',
263263
'Keywords': 'test,pdf,multipage',
264264
'ModDate': datetime(1968, 8, 1),
265+
'Trapped': 'Unknown'
265266
}
266267

267268
path = os.path.join(result_dir, 'pdfpages_meta.pdf')

0 commit comments

Comments
 (0)
0