Feature
Expected Result
Actual Result
>>>>> a = \
SyntaxError: Got unexpected token Newline at line 2 column 1
|
fn shell_exec(vm: &VirtualMachine, source: &str, scope: Scope) -> ShellExecResult { |
|
match vm.compile(source, compile::Mode::Single, "<stdin>".to_owned()) { |
|
Ok(code) => match vm.run_code_obj(code, scope) { |
|
Ok(_val) => ShellExecResult::Ok, |
|
Err(err) => ShellExecResult::PyErr(err), |
|
}, |
|
Err(CompileError { |
|
error: CompileErrorType::Parse(ParseErrorType::EOF), |
|
.. |
|
}) => ShellExecResult::Continue, |
|
Err(err) => ShellExecResult::PyErr(vm.new_syntax_error(&err)), |
|
} |
|
} |
In the current code, if vm.compile return ParseErrorType::EOF, return ShellExecResult::Continue to receive the next line.
However, if the lexer returns EOF after \\, the parser raises unexpected token error andParseErrorType::EOF does not occur, so ShellExecResult :: Continue is not returned.
https://github.com/python/cpython/blob/4a12d121860fb60d56cdcc212817577cac2356d0/Parser/tokenizer.c#L1753-L1771
In cpython code, an error occurred when EOF after \\ in the lexer step.
Feature
Expected Result
Actual Result
RustPython/src/shell.rs
Lines 20 to 32 in baf3ec1
In the current code, if
vm.compilereturnParseErrorType::EOF, returnShellExecResult::Continueto receive the next line.However, if the lexer returns EOF after
\\, the parser raisesunexpected token errorandParseErrorType::EOFdoes not occur, soShellExecResult :: Continueis not returned.https://github.com/python/cpython/blob/4a12d121860fb60d56cdcc212817577cac2356d0/Parser/tokenizer.c#L1753-L1771
In cpython code, an error occurred when EOF after
\\in the lexer step.