Skip to content

Commit c968d77

Browse files
committed
Handle null source sections in DSL intepreter
1 parent 14b284a commit c968d77

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/CodeBuiltins.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -490,14 +490,16 @@ Object positions(PCode self) {
490490
continue;
491491
}
492492
SourceSection section = rootNode.getSourceSectionForLocation(instruction.getLocation());
493-
lines.add(PFactory.createTuple(language, new int[]{
494-
section.getStartLine(),
495-
section.getEndLine(),
496-
// 1-based inclusive to 0-based inclusive
497-
section.getStartColumn() - 1,
498-
// 1-based inclusive to 0-based exclusive (-1 + 1 = 0)
499-
section.getEndColumn()
500-
}));
493+
if (section != null) {
494+
lines.add(PFactory.createTuple(language, new int[]{
495+
section.getStartLine(),
496+
section.getEndLine(),
497+
// 1-based inclusive to 0-based inclusive
498+
section.getStartColumn() - 1,
499+
// 1-based inclusive to 0-based exclusive (-1 + 1 = 0)
500+
section.getEndColumn()
501+
}));
502+
}
501503
}
502504
} else {
503505
BytecodeCodeUnit bytecodeCo = (BytecodeCodeUnit) co;

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode_dsl/PBytecodeDSLRootNode.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,11 @@ protected Source getSource() {
892892

893893
@TruffleBoundary
894894
public int bciToLine(int bci, BytecodeNode bytecodeNode) {
895-
return getSourceSectionForLocation(bci, bytecodeNode).getStartLine();
895+
SourceSection sourceSection = getSourceSectionForLocation(bci, bytecodeNode);
896+
if (sourceSection != null) {
897+
return sourceSection.getStartLine();
898+
}
899+
return -1;
896900
}
897901

898902
@TruffleBoundary

0 commit comments

Comments
 (0)