##// END OF EJS Templates
Fix bug with magic names in multi-line strings. run_cell now uses inputsplitter for static transformations.
Thomas Kluyver -
Show More
@@ -2106,23 +2106,27 b' class InteractiveShell(Configurable, Magic):'
2106 2106 self.showtraceback()
2107 2107 warn('Unknown failure executing file: <%s>' % fname)
2108 2108
2109 def run_cell(self, cell, store_history=True):
2109 def run_cell(self, raw_cell, store_history=True):
2110 2110 """Run a complete IPython cell.
2111 2111
2112 2112 Parameters
2113 2113 ----------
2114 cell : str
2114 raw_cell : str
2115 2115 The code (including IPython code such as %magic functions) to run.
2116 2116 store_history : bool
2117 2117 If True, the raw and translated cell will be stored in IPython's
2118 2118 history. For user code calling back into IPython's machinery, this
2119 2119 should be set to False.
2120 2120 """
2121 if not cell.strip():
2121 if not raw_cell.strip():
2122 2122 return
2123 2123
2124 raw_cell = cell
2124 for line in raw_cell.splitlines():
2125 self.input_splitter.push(line)
2126 cell = self.input_splitter.source_reset()
2127
2125 2128 with self.builtin_trap:
2129 if len(cell.splitlines()) == 1:
2126 2130 cell = self.prefilter_manager.prefilter_lines(cell)
2127 2131
2128 2132 # Store raw and processed history
@@ -89,5 +89,5 b' class InteractiveShellTestCase(unittest.TestCase):'
89 89
90 90 def test_magic_names_in_string(self):
91 91 ip = get_ipython()
92 ip.run_cell('"""\n%exit\n"""')
93 self.assertEquals(ip.user_ns['In'][-1], '\n%exit\n')
92 ip.run_cell('a = """\n%exit\n"""')
93 self.assertEquals(ip.user_ns['a'], '\n%exit\n')
General Comments 0
You need to be logged in to leave comments. Login now