Show More
@@ -2094,23 +2094,28 b' class InteractiveShell(Configurable, Magic):' | |||||
2094 | # Store the untransformed code |
|
2094 | # Store the untransformed code | |
2095 | raw_cell = cell |
|
2095 | raw_cell = cell | |
2096 |
|
2096 | |||
2097 | # We need to break up the input into executable blocks that can be run |
|
2097 | ||
2098 | # in 'single' mode, to provide comfortable user behavior. |
|
2098 | # Code transformation and execution must take place with our | |
|
2099 | # modifications to builtins. | |||
|
2100 | with self.builtin_trap: | |||
|
2101 | ||||
|
2102 | # We need to break up the input into executable blocks that can | |||
|
2103 | # be runin 'single' mode, to provide comfortable user behavior. | |||
2099 | blocks = self.input_splitter.split_blocks(cell) |
|
2104 | blocks = self.input_splitter.split_blocks(cell) | |
2100 |
|
2105 | |||
2101 | if not blocks: # Blank cell |
|
2106 | if not blocks: # Blank cell | |
2102 | return |
|
2107 | return | |
2103 |
|
2108 | |||
2104 |
# We only do dynamic transforms on a single line. But a macro |
|
2109 | # We only do dynamic transforms on a single line. But a macro | |
2105 |
# be expanded to several lines, so we need to split it |
|
2110 | # can be expanded to several lines, so we need to split it | |
2106 | # blocks again. |
|
2111 | # into input blocks again. | |
2107 | if len(cell.splitlines()) <= 1: |
|
2112 | if len(cell.splitlines()) <= 1: | |
2108 | cell = self.prefilter_manager.prefilter_line(blocks[0]) |
|
2113 | cell = self.prefilter_manager.prefilter_line(blocks[0]) | |
2109 | blocks = self.input_splitter.split_blocks(cell) |
|
2114 | blocks = self.input_splitter.split_blocks(cell) | |
2110 |
|
2115 | |||
2111 |
# Store the 'ipython' version of the cell as well, since |
|
2116 | # Store the 'ipython' version of the cell as well, since | |
2112 |
# needs to go into the translated history and get |
|
2117 | # that's what needs to go into the translated history and get | |
2113 | # original cell may contain non-python syntax). |
|
2118 | # executed (the original cell may contain non-python syntax). | |
2114 | cell = ''.join(blocks) |
|
2119 | cell = ''.join(blocks) | |
2115 |
|
2120 | |||
2116 | # Store raw and processed history |
|
2121 | # Store raw and processed history | |
@@ -2120,8 +2125,9 b' class InteractiveShell(Configurable, Magic):' | |||||
2120 |
|
2125 | |||
2121 | self.logger.log(cell, raw_cell) |
|
2126 | self.logger.log(cell, raw_cell) | |
2122 |
|
2127 | |||
2123 |
# All user code execution |
|
2128 | # All user code execution should take place with our | |
2124 | with nested(self.builtin_trap, self.display_trap): |
|
2129 | # modified displayhook. | |
|
2130 | with self.display_trap: | |||
2125 |
|
2131 | |||
2126 | # Single-block input should behave like an interactive prompt |
|
2132 | # Single-block input should behave like an interactive prompt | |
2127 | if len(blocks) == 1: |
|
2133 | if len(blocks) == 1: | |
@@ -2130,7 +2136,8 b' class InteractiveShell(Configurable, Magic):' | |||||
2130 | # history output logging is enabled. |
|
2136 | # history output logging is enabled. | |
2131 | if store_history: |
|
2137 | if store_history: | |
2132 | self.history_manager.store_output(self.execution_count) |
|
2138 | self.history_manager.store_output(self.execution_count) | |
2133 |
|
|
2139 | # Since we return here, we need to update the | |
|
2140 | # execution count | |||
2134 | self.execution_count += 1 |
|
2141 | self.execution_count += 1 | |
2135 | return out |
|
2142 | return out | |
2136 |
|
2143 | |||
@@ -2151,7 +2158,8 b' class InteractiveShell(Configurable, Magic):' | |||||
2151 | retcode = self.run_source(ipy_body, symbol='exec', |
|
2158 | retcode = self.run_source(ipy_body, symbol='exec', | |
2152 | post_execute=False) |
|
2159 | post_execute=False) | |
2153 | if retcode==0: |
|
2160 | if retcode==0: | |
2154 |
# Last expression compiled as 'single' so it |
|
2161 | # Last expression compiled as 'single' so it | |
|
2162 | # produces output | |||
2155 | self.run_source(last) |
|
2163 | self.run_source(last) | |
2156 | else: |
|
2164 | else: | |
2157 | # Run the whole cell as one entity, storing both raw and |
|
2165 | # Run the whole cell as one entity, storing both raw and |
General Comments 0
You need to be logged in to leave comments.
Login now