From 0a39869469bce22793c2f27b2f030157f0e0c9a5 2013-03-31 09:03:53 From: Thomas Kluyver Date: 2013-03-31 09:03:53 Subject: [PATCH] Inputsplitter flushes transformers before retrieving source. --- diff --git a/IPython/core/inputsplitter.py b/IPython/core/inputsplitter.py index ebfe779..eb1f8fb 100644 --- a/IPython/core/inputsplitter.py +++ b/IPython/core/inputsplitter.py @@ -524,14 +524,30 @@ class IPythonInputSplitter(InputSplitter): self._buffer_raw[:] = [] self.source_raw = '' self.transformer_accumulating = False + for t in self.transforms: + t.reset() + + def flush_transformers(self): + out = None + for t in self.transforms: + tmp = t.reset() + if tmp: + out = tmp + if out: + self._store(out) def source_raw_reset(self): """Return input and raw source and perform a full reset. """ + self.flush_transformers() out = self.source out_r = self.source_raw self.reset() return out, out_r + + def source_reset(self): + self.flush_transformers() + return super(IPythonInputSplitter, self).source_reset() def push_accepts_more(self): if self.transformer_accumulating: diff --git a/IPython/core/inputtransformer.py b/IPython/core/inputtransformer.py index 106dcb7..5beccf4 100644 --- a/IPython/core/inputtransformer.py +++ b/IPython/core/inputtransformer.py @@ -66,7 +66,7 @@ class CoroutineInputTransformer(InputTransformer): return self.coro.send(line) def reset(self): - self.coro.send(None) + return self.coro.send(None) # Utilities