From 4600d5526c0c418bdc2f169530fa5d1289b55539 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20Wobst?= Date: Thu, 29 Mar 2018 06:49:26 +0000 Subject: [PATCH] prevent double call of _cleanup, which harms usefiles (and is a bad idea in general) git-svn-id: http://svn.code.sf.net/p/pyx/code/trunk/pyx@3687 a4f5e268-e194-4f32-bce1-d30804cbbcc5 --- pyx/text.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pyx/text.py b/pyx/text.py index c2dd33b4..641180f2 100644 --- a/pyx/text.py +++ b/pyx/text.py @@ -1023,7 +1023,7 @@ class SingleRunner: try: if self.state > STATE_START: if self.state < STATE_DONE: - self.do_finish() + self.do_finish(cleanup=False) if self.state < STATE_DONE: # cleanup while TeX is still running? self.texoutput.expect(None) self.force_done() @@ -1213,8 +1213,11 @@ class SingleRunner: self.go_typeset() return self._execute(expr, texmessages, STATE_TYPESET, STATE_TYPESET) - def do_finish(self): - """Teardown TeX interpreter and cleanup environment.""" + def do_finish(self, cleanup=True): + """Teardown TeX interpreter and cleanup environment. + + :param bool cleanup: use _cleanup regularly/explicitly (not via atexit) + """ if self.state == STATE_DONE: return if self.state < STATE_TYPESET: @@ -1233,9 +1236,9 @@ class SingleRunner: page += 1 if self.dvifile is not None and self.dvifile.readpage(None) is not None: raise ValueError("end of dvifile expected but further pages follow") - - atexit.unregister(self._cleanup) - self._cleanup() + if cleanup: + atexit.unregister(self._cleanup) + self._cleanup() def preamble(self, expr, texmessages=[]): """Execute a preamble. -- 2.11.4.GIT