Skip to content

Commit 7c11a13

Browse files
committed
fix NullPointerException on syntax error message creation
1 parent ce97ceb commit 7c11a13

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/parser/PythonErrorStrategy.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
import org.antlr.v4.runtime.InputMismatchException;
4343
import org.antlr.v4.runtime.NoViableAltException;
4444
import org.antlr.v4.runtime.Parser;
45-
import org.antlr.v4.runtime.ParserRuleContext;
4645
import org.antlr.v4.runtime.RecognitionException;
4746
import org.antlr.v4.runtime.Token;
4847
import org.antlr.v4.runtime.TokenStream;
@@ -102,14 +101,7 @@ private static void handlePythonSyntaxError(Parser recognizer, RecognitionExcept
102101
String lineText = getTokeLineText(recognizer, offendingToken);
103102
String errorMarker = new String(new char[offendingToken.getCharPositionInLine()]).replace('\0', ' ') + "^";
104103
String pythonSyntaxErrorMessage = "\n" + LINE_PADDING + lineText + "\n" + LINE_PADDING + errorMarker;
105-
106-
RecognitionException re = e;
107-
// the error message in some cases is not set properly producing an annoying "null" in the
108-
// final message, we replace the error with a copy of itself and an empty message
109-
if (re.getMessage() == null) {
110-
re = new RecognitionException("", e.getRecognizer(), e.getInputStream(), (ParserRuleContext) e.getCtx());
111-
}
112-
recognizer.notifyErrorListeners(offendingToken, pythonSyntaxErrorMessage, re);
104+
recognizer.notifyErrorListeners(offendingToken, pythonSyntaxErrorMessage, e);
113105
}
114106

115107
@Override

0 commit comments

Comments
 (0)