Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Lib/codeop.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ def _maybe_compile(compiler, source, filename, symbol):
compiler(source + "\n", filename, symbol)
return None
except SyntaxError as e:
if "incomplete input" in str(e):
# XXX: RustPython; support multiline definitions in REPL
# See also: https://github.com/RustPython/RustPython/pull/5743
strerr = str(e)
Comment thread
youknowone marked this conversation as resolved.
if source.endswith(":") and "expected an indented block" in strerr:
return None
elif "incomplete input" in str(e):
return None
# fallthrough

Expand Down
17 changes: 10 additions & 7 deletions src/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,16 @@ fn shell_exec(

let bad_error = match err {
CompileError::Parse(ref p) => {
if matches!(
p.error,
ParseErrorType::Lexical(LexicalErrorType::IndentationError)
) {
continuing // && p.location.is_some()
} else {
true // !matches!(p, ParseErrorType::UnrecognizedToken(Tok::Dedent, _))
match &p.error {
ParseErrorType::Lexical(LexicalErrorType::IndentationError) => continuing, // && p.location.is_some()
ParseErrorType::OtherError(msg) => {
if msg.starts_with("Expected an indented block") {
continuing
} else {
true
}
}
_ => true, // !matches!(p, ParseErrorType::UnrecognizedToken(Tok::Dedent, _))
}
}
_ => true, // It is a bad error for everything else
Expand Down