Skip to content

Commit 27cf8f0

Browse files
committed
use TruffleString in PythonLanguge.raiseSyntaxError()
1 parent ecb5fb0 commit 27cf8f0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -581,13 +581,13 @@ public SourceSection getSourceSection() {
581581
instance = PythonObjectFactory.getUncached().createBaseException(cls, message, PythonUtils.EMPTY_OBJECT_ARRAY);
582582
final Object[] excAttrs = SyntaxErrorBuiltins.SYNTAX_ERROR_ATTR_FACTORY.create();
583583
SourceSection section = location.getSourceSection();
584-
String path = source.getPath();
585-
excAttrs[SyntaxErrorBuiltins.IDX_FILENAME] = (path != null) ? path : source.getName() != null ? source.getName() : "<string>";
584+
TruffleString path = toTruffleStringUncached(source.getPath());
585+
excAttrs[SyntaxErrorBuiltins.IDX_FILENAME] = (path != null) ? path : source.getName() != null ? toTruffleStringUncached(source.getName()) : tsLiteral("<string>");
586586
excAttrs[SyntaxErrorBuiltins.IDX_LINENO] = section.getStartLine();
587587
excAttrs[SyntaxErrorBuiltins.IDX_OFFSET] = section.getStartColumn();
588588
// Not very nice. This counts on the implementation in traceback.py where if the value of
589589
// text attribute is NONE, then the line is not printed
590-
final String text = section.isAvailable() ? source.getCharacters(section.getStartLine()).toString() : null;
590+
final TruffleString text = section.isAvailable() ? toTruffleStringUncached(source.getCharacters(section.getStartLine()).toString()) : null;
591591
excAttrs[SyntaxErrorBuiltins.IDX_MSG] = message;
592592
excAttrs[SyntaxErrorBuiltins.IDX_TEXT] = text;
593593
instance.setExceptionAttributes(excAttrs);

0 commit comments

Comments
 (0)