Show More
@@ -2106,24 +2106,28 b' class InteractiveShell(Configurable, Magic):' | |||||
2106 | self.showtraceback() |
|
2106 | self.showtraceback() | |
2107 | warn('Unknown failure executing file: <%s>' % fname) |
|
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 | """Run a complete IPython cell. |
|
2110 | """Run a complete IPython cell. | |
2111 |
|
2111 | |||
2112 | Parameters |
|
2112 | Parameters | |
2113 | ---------- |
|
2113 | ---------- | |
2114 | cell : str |
|
2114 | raw_cell : str | |
2115 | The code (including IPython code such as %magic functions) to run. |
|
2115 | The code (including IPython code such as %magic functions) to run. | |
2116 | store_history : bool |
|
2116 | store_history : bool | |
2117 | If True, the raw and translated cell will be stored in IPython's |
|
2117 | If True, the raw and translated cell will be stored in IPython's | |
2118 | history. For user code calling back into IPython's machinery, this |
|
2118 | history. For user code calling back into IPython's machinery, this | |
2119 | should be set to False. |
|
2119 | should be set to False. | |
2120 | """ |
|
2120 | """ | |
2121 | if not cell.strip(): |
|
2121 | if not raw_cell.strip(): | |
2122 | return |
|
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 | with self.builtin_trap: |
|
2128 | with self.builtin_trap: | |
2126 | cell = self.prefilter_manager.prefilter_lines(cell) |
|
2129 | if len(cell.splitlines()) == 1: | |
|
2130 | cell = self.prefilter_manager.prefilter_lines(cell) | |||
2127 |
|
2131 | |||
2128 | # Store raw and processed history |
|
2132 | # Store raw and processed history | |
2129 | if store_history: |
|
2133 | if store_history: |
@@ -89,5 +89,5 b' class InteractiveShellTestCase(unittest.TestCase):' | |||||
89 |
|
89 | |||
90 | def test_magic_names_in_string(self): |
|
90 | def test_magic_names_in_string(self): | |
91 | ip = get_ipython() |
|
91 | ip = get_ipython() | |
92 | ip.run_cell('"""\n%exit\n"""') |
|
92 | ip.run_cell('a = """\n%exit\n"""') | |
93 |
self.assertEquals(ip.user_ns[' |
|
93 | self.assertEquals(ip.user_ns['a'], '\n%exit\n') |
General Comments 0
You need to be logged in to leave comments.
Login now