Skip to content

Commit 355c24f

Browse files
committed
StringUtils: fix error messages for syntax error based unicode decode exceptions
1 parent 3df2b8c commit 355c24f

File tree

1 file changed

+2
-2
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/parser/sst

1 file changed

+2
-2
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/parser/sst/StringUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public static void warnInvalidEscapeSequence(ParserErrorCallback errorCallback,
217217
private static final String TRUNCATED_XXX_ERROR = "truncated \\xXX escape";
218218
private static final String TRUNCATED_UXXXX_ERROR = "truncated \\uXXXX escape";
219219
private static final String TRUNCATED_UXXXXXXXX_ERROR = "truncated \\UXXXXXXXX escape";
220-
private static final String UNKNOWN_UNICODE_ERROR = " unknown Unicode character name";
220+
private static final String UNKNOWN_UNICODE_ERROR = "unknown Unicode character name";
221221
private static final String ILLEGAl_CHARACTER = "illegal Unicode character";
222222

223223
private static int getHexValue(String text, int start, int len) {
@@ -283,7 +283,7 @@ private static int doCharacterName(String text, StringBuilder sb, int offset) {
283283
if (cp >= 0) {
284284
sb.append(Character.toChars(cp));
285285
} else {
286-
throw PConstructAndRaiseNode.raiseUncachedUnicodeDecodeError("unicodeescape", text, offset - 2, closeIndex, UNKNOWN_UNICODE_ERROR);
286+
throw PConstructAndRaiseNode.raiseUncachedUnicodeDecodeError("unicodeescape", text, offset - 2, text.length(), UNKNOWN_UNICODE_ERROR);
287287
}
288288
return closeIndex;
289289
}

0 commit comments

Comments
 (0)