Line continuation character does not work properly in python shell. · Issue #1928 · RustPython/RustPython · GitHub
Skip to content

Line continuation character does not work properly in python shell. #1928

Description

@HyeockJinKim

Feature

Expected Result

>>> a = \
... 

Actual Result

>>>>> a = \
SyntaxError: Got unexpected token Newline at line 2 column 1

RustPython/src/shell.rs

Lines 20 to 32 in baf3ec1

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-compatA discrepancy between RustPython and CPython

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions