From 203d1998e29f72c24ebd9dfd20df376f3c1aa03b Mon Sep 17 00:00:00 2001 From: kth496 Date: Wed, 13 Jul 2022 16:47:58 +0900 Subject: [PATCH] Fix multiline lexer bug Co-authored-by: Hyeonji-Ryu --- Lib/test/test_grammar.py | 2 -- parser/src/lexer.rs | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py index c65426768..c7076252c 100644 --- a/Lib/test/test_grammar.py +++ b/Lib/test/test_grammar.py @@ -257,8 +257,6 @@ the \'lazy\' dog.\n\ self.assertTrue(x is Ellipsis) self.assertRaises(SyntaxError, eval, ".. .") - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_eof_error(self): samples = ("def foo(", "\ndef foo(", "def foo(\n") for s in samples: diff --git a/parser/src/lexer.rs b/parser/src/lexer.rs index ac46b10bc..3cea29b33 100644 --- a/parser/src/lexer.rs +++ b/parser/src/lexer.rs @@ -568,7 +568,7 @@ where } else { if (c == '\n' && !triple_quoted) || (is_bytes && !c.is_ascii()) { return Err(LexicalError { - error: LexicalErrorType::StringError, + error: LexicalErrorType::Eof, location: self.get_pos(), }); } @@ -784,7 +784,7 @@ where // First of all, we need all nestings to be finished. if self.nesting > 0 { return Err(LexicalError { - error: LexicalErrorType::NestingError, + error: LexicalErrorType::Eof, location: tok_pos, }); }