@@ -984,6 +984,10 @@ def _print_figure(
984
984
if isinstance (outfile ,
985
985
(six .string_types , getattr (os , "PathLike" , ()),)):
986
986
outfile = title = getattr (os , "fspath" , lambda obj : obj )(outfile )
987
+ try :
988
+ title .encode ("latin-1" )
989
+ except UnicodeEncodeError :
990
+ title = None
987
991
passed_in_file_object = False
988
992
elif is_writable_file_like (outfile ):
989
993
title = None
@@ -1071,7 +1075,7 @@ def print_figure_impl(fh):
1071
1075
else :
1072
1076
print ("%!PS-Adobe-3.0" , file = fh )
1073
1077
if title :
1074
- print ("%%Title: " + title , file = fh )
1078
+ print ("%%Title: " + title , file = fh )
1075
1079
print ("%%Creator: " + creator_str , file = fh )
1076
1080
# get source date from SOURCE_DATE_EPOCH, if set
1077
1081
# See https://reproducible-builds.org/specs/source-date-epoch/
@@ -1081,7 +1085,7 @@ def print_figure_impl(fh):
1081
1085
int (source_date_epoch )).strftime ("%a %b %d %H:%M:%S %Y" )
1082
1086
else :
1083
1087
source_date = time .ctime ()
1084
- print ("%%CreationDate: " + source_date , file = fh )
1088
+ print ("%%CreationDate: " + source_date , file = fh )
1085
1089
print ("%%Orientation: " + orientation , file = fh )
1086
1090
if not isEPSF :
1087
1091
print ("%%DocumentPaperSizes: " + papertype , file = fh )
0 commit comments