Show More
@@ -179,14 +179,21 b' class BlockBreaker(object):' | |||
|
179 | 179 | # exception is raised in compilation, we don't mislead by having |
|
180 | 180 | # inconsistent code/source attributes. |
|
181 | 181 | self.code, self.is_complete = None, None |
|
182 | self.code = self.compile(source) | |
|
183 | # Compilation didn't produce any exceptions (though it may not have | |
|
184 | # given a complete code object) | |
|
185 | if self.code is None: | |
|
186 | self.is_complete = False | |
|
187 | else: | |
|
182 | try: | |
|
183 | self.code = self.compile(source) | |
|
184 | # Invalid syntax can produce any of a number of different errors from | |
|
185 | # inside the compiler, so we have to catch them all. Syntax errors | |
|
186 | # immediately produce a 'ready' block, so the invalid Python can be | |
|
187 | # sent to the kernel for evaluation with possible ipython | |
|
188 | # special-syntax conversion. | |
|
189 | except (SyntaxError, OverflowError, ValueError, TypeError, MemoryError): | |
|
188 | 190 | self.is_complete = True |
|
189 | self._update_indent(lines) | |
|
191 | else: | |
|
192 | # Compilation didn't produce any exceptions (though it may not have | |
|
193 | # given a complete code object) | |
|
194 | self.is_complete = self.code is not None | |
|
195 | self._update_indent(lines) | |
|
196 | ||
|
190 | 197 | return self.is_complete |
|
191 | 198 | |
|
192 | 199 | def interactive_block_ready(self): |
@@ -181,3 +181,11 b' class BlockBreakerTestCase(unittest.TestCase):' | |||
|
181 | 181 | self.assertFalse(bb.interactive_block_ready()) |
|
182 | 182 | bb.push('') |
|
183 | 183 | self.assertTrue(bb.interactive_block_ready()) |
|
184 | ||
|
185 | def test_syntax_error(self): | |
|
186 | bb = self.bb | |
|
187 | # Syntax errors immediately produce a 'ready' block, so the invalid | |
|
188 | # Python can be sent to the kernel for evaluation with possible ipython | |
|
189 | # special-syntax conversion. | |
|
190 | bb.push('run foo') | |
|
191 | self.assertTrue(bb.interactive_block_ready()) |
General Comments 0
You need to be logged in to leave comments.
Login now