@@ -469,7 +469,7 @@ def draw_image(self, gc, x, y, im, dx=None, dy=None, transform=None):
469
469
im .flipud_out ()
470
470
471
471
h , w , bits , imagecmd = self ._get_image_h_w_bits_command (im )
472
- hexlines = '\n ' .join (self ._hex_lines (bits ))
472
+ hexlines = b '\n ' .join (self ._hex_lines (bits )). decode ( 'ascii' )
473
473
474
474
if dx is None :
475
475
xscale = w / self .image_magnification
@@ -1179,6 +1179,7 @@ def write(self, *kl, **kwargs):
1179
1179
print ("end" , file = fh )
1180
1180
print ("showpage" , file = fh )
1181
1181
if not isEPSF : print ("%%EOF" , file = fh )
1182
+ fh .flush ()
1182
1183
1183
1184
if rcParams ['ps.usedistiller' ] == 'ghostscript' :
1184
1185
gs_distill (tmpfile , isEPSF , ptype = papertype , bbox = bbox )
@@ -1187,7 +1188,7 @@ def write(self, *kl, **kwargs):
1187
1188
1188
1189
if passed_in_file_object :
1189
1190
with open (tmpfile , 'rb' ) as fh :
1190
- print (fh .read (), file = outfile )
1191
+ outfile . write (fh .read ())
1191
1192
else :
1192
1193
with open (outfile , 'w' ) as fh :
1193
1194
pass
@@ -1293,6 +1294,7 @@ def write(self, *kl, **kwargs):
1293
1294
#print >>fh, "grestore"
1294
1295
print ("end" , file = fh )
1295
1296
print ("showpage" , file = fh )
1297
+ fh .flush ()
1296
1298
1297
1299
if isLandscape : # now we are ready to rotate
1298
1300
isLandscape = True
0 commit comments