@@ -232,6 +232,8 @@ def _cleanup_remaining_instances():
232
232
latex_manager ._cleanup ()
233
233
234
234
def _stdin_writeln (self , s ):
235
+ if self .latex is None :
236
+ self ._setup_latex_process ()
235
237
self .latex .stdin .write (s )
236
238
self .latex .stdin .write ("\n " )
237
239
self .latex .stdin .flush ()
@@ -245,6 +247,8 @@ def _expect(self, s):
245
247
if chars [- len (s ):] == s :
246
248
break
247
249
if not c :
250
+ self .latex .kill ()
251
+ self .latex = None
248
252
raise LatexError ("LaTeX process halted" , "" .join (chars ))
249
253
return "" .join (chars )
250
254
@@ -281,6 +285,10 @@ def __init__(self):
281
285
raise LatexError ("LaTeX returned an error, probably missing font "
282
286
"or error in preamble:\n %s" % stdout )
283
287
288
+ self .latex = None # Will be set up on first use.
289
+ self .str_cache = {} # cache for strings already processed
290
+
291
+ def _setup_latex_process (self ):
284
292
# open LaTeX process for real work
285
293
self .latex = subprocess .Popen (
286
294
[self .texcommand , "-halt-on-error" ],
@@ -292,9 +300,6 @@ def __init__(self):
292
300
self ._expect ("*pgf_backend_query_start" )
293
301
self ._expect_prompt ()
294
302
295
- # cache for strings already processed
296
- self .str_cache = {}
297
-
298
303
@cbook .deprecated ("3.3" )
299
304
def latex_stdin_utf8 (self ):
300
305
return self .latex .stdin
@@ -408,10 +413,10 @@ def __init__(self, figure, fh, dummy=False):
408
413
else :
409
414
# if fh does not belong to a filename, deactivate draw_image
410
415
if not hasattr (fh , 'name' ) or not os .path .exists (fh .name ):
411
- cbook . _warn_external ( "streamed pgf-code does not support "
412
- "raster graphics, consider using the "
413
- "pgf-to-pdf option" , UserWarning )
414
- self . __dict__ [ "draw_image" ] = lambda * args , ** kwargs : None
416
+ self . __dict__ [ "draw_image" ] = \
417
+ lambda * args , ** kwargs : cbook . _warn_external (
418
+ "streamed pgf-code does not support raster graphics, "
419
+ "consider using the pgf-to-pdf option" )
415
420
416
421
@cbook .deprecated ("3.2" )
417
422
def latexManager (self ):
0 commit comments