diff options
author | Benjamin Peterson <benjamin@python.org> | 2011-05-30 16:12:38 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2011-05-30 16:12:38 (GMT) |
commit | 758888d437c4c2d398ec322ff1596e1620f5f0dd (patch) | |
tree | 0d8f30a733d4a4afd42b3700d1433ef00f2fc5f3 /Lib/test/test_grammar.py | |
parent | c8507bfe9cd581de1b324af92bf255a86a0437b0 (diff) | |
download | cpython-758888d437c4c2d398ec322ff1596e1620f5f0dd.zip cpython-758888d437c4c2d398ec322ff1596e1620f5f0dd.tar.gz cpython-758888d437c4c2d398ec322ff1596e1620f5f0dd.tar.bz2 |
don't restrict unexpected EOF errors to the first line (closes #12216)
Diffstat (limited to 'Lib/test/test_grammar.py')
-rw-r--r-- | Lib/test/test_grammar.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py index 9953363..32dc15e 100644 --- a/Lib/test/test_grammar.py +++ b/Lib/test/test_grammar.py @@ -125,6 +125,13 @@ the \'lazy\' dog.\n\ self.assertTrue(x is Ellipsis) self.assertRaises(SyntaxError, eval, ".. .") + def test_eof_error(self): + samples = ("def foo(", "\ndef foo(", "def foo(\n") + for s in samples: + with self.assertRaises(SyntaxError) as cm: + compile(s, "<test>", "exec") + self.assertIn("unexpected EOF", str(cm.exception)) + class GrammarTests(unittest.TestCase): # single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE |