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 | try: | |
|
182 | 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): | |
|
190 | self.is_complete = True | |
|
191 | else: | |
|
183 | 192 | # Compilation didn't produce any exceptions (though it may not have |
|
184 | 193 | # given a complete code object) |
|
185 |
|
|
|
186 | self.is_complete = False | |
|
187 | else: | |
|
188 | self.is_complete = True | |
|
194 | self.is_complete = self.code is not None | |
|
189 | 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