##// END OF EJS Templates
Line continuations now terminate after one blank line (#2108)...
Aaron Meurer -
Show More
@@ -369,7 +369,7 b' class InputSplitter(object):'
369 self.code, self._is_complete = None, None
369 self.code, self._is_complete = None, None
370
370
371 # Honor termination lines properly
371 # Honor termination lines properly
372 if source.rstrip().endswith('\\'):
372 if source.endswith('\\\n'):
373 return False
373 return False
374
374
375 self._update_indent(lines)
375 self._update_indent(lines)
@@ -351,6 +351,22 b' class InputSplitterTestCase(unittest.TestCase):'
351 self.isp.push(u'\xc3\xa9')
351 self.isp.push(u'\xc3\xa9')
352 self.isp.push(u"u'\xc3\xa9'")
352 self.isp.push(u"u'\xc3\xa9'")
353
353
354 def test_line_continuation(self):
355 """ Test issue #2108."""
356 isp = self.isp
357 # A blank line after a line continuation should not accept more
358 isp.push("1 \\\n\n")
359 self.assertFalse(isp.push_accepts_more())
360 # Whitespace after a \ is a SyntaxError. The only way to test that
361 # here is to test that push doesn't accept more (as with
362 # test_syntax_error() above).
363 isp.push(r"1 \ ")
364 self.assertFalse(isp.push_accepts_more())
365 # Even if the line is continuable (c.f. the regular Python
366 # interpreter)
367 isp.push(r"(1 \ ")
368 self.assertFalse(isp.push_accepts_more())
369
354 class InteractiveLoopTestCase(unittest.TestCase):
370 class InteractiveLoopTestCase(unittest.TestCase):
355 """Tests for an interactive loop like a python shell.
371 """Tests for an interactive loop like a python shell.
356 """
372 """
General Comments 0
You need to be logged in to leave comments. Login now