Permalink
Browse files

Remove runlines method and calls to it.

  • Loading branch information...
1 parent bb38481 commit 07aea6a7d2f29fb67ccb29f97ca639a4f8aba421 @takluyver committed Apr 12, 2011
@@ -2224,52 +2224,6 @@ def run_ast_nodes(self, nodelist, cell_name, interactivity='last_expr'):
return False
-
- # PENDING REMOVAL: this method is slated for deletion, once our new
- # input logic has been 100% moved to frontends and is stable.
- def runlines(self, lines, clean=False):
- """Run a string of one or more lines of source.
-
- This method is capable of running a string containing multiple source
- lines, as if they had been entered at the IPython prompt. Since it
- exposes IPython's processing machinery, the given strings can contain
- magic calls (%magic), special shell access (!cmd), etc.
- """
-
- if not isinstance(lines, (list, tuple)):
- lines = lines.splitlines()
-
- if clean:
- lines = self._cleanup_ipy_script(lines)
-
- # We must start with a clean buffer, in case this is run from an
- # interactive IPython session (via a magic, for example).
- self.reset_buffer()
-
- # Since we will prefilter all lines, store the user's raw input too
- # before we apply any transformations
- self.buffer_raw[:] = [ l+'\n' for l in lines]
-
- more = False
- prefilter_lines = self.prefilter_manager.prefilter_lines
- with nested(self.builtin_trap, self.display_trap):
- for line in lines:
- # skip blank lines so we don't mess up the prompt counter, but
- # do NOT skip even a blank line if we are in a code block (more
- # is true)
-
- if line or more:
- more = self.push_line(prefilter_lines(line, more))
- # IPython's run_source returns None if there was an error
- # compiling the code. This allows us to stop processing
- # right away, so the user gets the error message at the
- # right place.
- if more is None:
- break
- # final newline in case the input didn't have it, so that the code
- # actually does get executed
- if more:
- self.push_line('\n')
def run_source(self, source, filename=None, symbol='single'):
"""Compile and run some source in the interpreter.
@@ -237,10 +237,10 @@ def doctest_tb_sysexit():
"""
-def test_runlines():
+def test_run_cell():
import textwrap
- ip.runlines(['a = 10', 'a+=1'])
- ip.runlines('assert a == 11\nassert 1')
+ ip.run_cell('a = 10\na+=1')
+ ip.run_cell('assert a == 11\nassert 1')
nt.assert_equals(ip.user_ns['a'], 11)
complex = textwrap.dedent("""
@@ -260,7 +260,7 @@ def test_runlines():
""")
# Simply verifies that this kind of input is run
- ip.runlines(complex)
+ ip.run_cell(complex)
def test_db():
@@ -151,7 +151,7 @@ def test_simpledef(self):
"def f(): return foo()")
self.mktmp(src)
_ip.magic('run %s' % self.fname)
- _ip.runlines('t = isinstance(f(), foo)')
+ _ip.run_cell('t = isinstance(f(), foo)')
nt.assert_true(_ip.user_ns['t'])
# We have to skip these in win32 because getoutputerr() crashes,
@@ -188,7 +188,7 @@ class secondtmp(tt.TempFileMixin): pass
" print i;break\n" % empty.fname)
self.mktmp(src)
_ip.magic('run %s' % self.fname)
- _ip.runlines('ip == get_ipython()')
+ _ip.run_cell('ip == get_ipython()')
tt.assert_equals(_ip.user_ns['i'], 5)
@dec.skip_win32
@@ -241,7 +241,7 @@ def execute_request(self, ident, parent):
except:
status = u'error'
# FIXME: this code right now isn't being used yet by default,
- # because the runlines() call above directly fires off exception
+ # because the run_cell() call above directly fires off exception
# reporting. This code, therefore, is only active in the scenario
# where runlines itself has an unhandled exception. We need to
# uniformize this, for all exception construction to come from a

0 comments on commit 07aea6a

Please sign in to comment.