8000 Don't include the postscript title if it is not latin-1 encodable. · matplotlib/matplotlib@099efbc · GitHub
[go: up one dir, main page]

Skip to content

Commit 099efbc

Browse files
committed
Don't include the postscript title if it is not latin-1 encodable.
1 parent 634640f commit 099efbc

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/matplotlib/backends/backend_ps.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,10 @@ def _print_figure(
984984
if isinstance(outfile,
985985
(six.string_types, getattr(os, "PathLike", ()),)):
986986
outfile = title = getattr(os, "fspath", lambda obj: obj)(outfile)
987+
try:
988+
title.encode("latin-1")
989+
except UnicodeEncodeError:
990+
title = None
987991
passed_in_file_object = False
988992
elif is_writable_file_like(outfile):
989993
title = None
@@ -1071,7 +1075,7 @@ def print_figure_impl(fh):
10711075
else:
10721076
print("%!PS-Adobe-3.0", file=fh)
10731077
if title:
1074-
print("%%Title: "+title, file=fh)
1078+
print("%%Title: " + title, file=fh)
10751079
print("%%Creator: " + creator_str, file=fh)
10761080
# get source date from SOURCE_DATE_EPOCH, if set
10771081
# See https://reproducible-builds.org/specs/source-date-epoch/
@@ -1081,7 +1085,7 @@ def print_figure_impl(fh):
10811085
int(source_date_epoch)).strftime("%a %b %d %H:%M:%S %Y")
10821086
else:
10831087
source_date = time.ctime()
1084-
print("%%CreationDate: "+source_date, file=fh)
1088+
print("%%CreationDate: " + source_date, file=fh)
10851089
print("%%Orientation: " + orientation, file=fh)
10861090
if not isEPSF:
10871091
print("%%DocumentPaperSizes: "+papertype, file=fh)

0 commit comments

Comments
 (0)
0