Skip to content

Commit f3089aa

Browse files
committed
[GR-28188] Is not possible to write in REPL formatted multiline text
PullRequest: graalpython/1670
2 parents e0a996a + 5333002 commit f3089aa

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/parser/antlr/DescriptiveBailErrorListener.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ private static PIncompleteSourceException handleRecognitionException(IntervalSet
170170
}
171171
}
172172

173+
if (tokenId == Python3Parser.NEWLINE && (et.contains(Python3Parser.FINALLY) || et.contains(Python3Parser.EXCEPT))) {
174+
return new PIncompleteSourceException("", null, -1);
175+
}
176+
173177
if ((tokenId != Python3Parser.INDENT_ERROR && tokenId != Python3Parser.TAB_ERROR && tokenId != Python3Parser.INDENT && tokenId != Python3Parser.DEDENT) &&
174178
(et.contains(Python3Parser.INDENT) || et.contains(Python3Parser.NEWLINE) && et.size() == 1)) {
175179
return new PIncompleteSourceException(message, cause, line);
@@ -186,6 +190,12 @@ private static PIncompleteSourceException handleInteractiveException(Recognizer<
186190
if (tokenId == Python3Parser.LONG_QUOTES1 || tokenId == Python3Parser.LONG_QUOTES2) {
187191
return new PIncompleteSourceException("", null, -1);
188192
}
193+
if (tokenId == Python3Parser.UNKNOWN_CHAR) {
194+
String text = token.getText();
195+
if (text.startsWith("\'") || text.startsWith("\"")) {
196+
return new PIncompleteSourceException("", null, -1);
197+
}
198+
}
189199
if (isOpened(((Python3Parser) recognizer).getTokenStream())) {
190200
// The assumption is:
191201
// Look ahead and if there are other tokens (except new lines and EOF),

0 commit comments

Comments
 (0)