Skip to content

Commit aa15d7f

Browse files
committed
Don't use context in PCode.toString
1 parent 54d8ee1 commit aa15d7f

File tree

1 file changed

+8
-1
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,14 @@ public boolean hasSourceLocation(@Exclusive @Cached GilNode gil) {
746746
@TruffleBoundary
747747
public String toString() {
748748
String codeName = this.getName() == null ? "None" : this.getName().toJavaStringUncached();
749-
String codeFilename = this.getFilename() == null ? "None" : this.getFilename().toJavaStringUncached();
749+
/*
750+
* This might be called without an active context (i.e. when dumping graphs), we cannot use
751+
* getFilename
752+
*/
753+
String codeFilename = getSourceSectionFileName(rootNodeForExtraction(getRootNode()).getSourceSection());
754+
if (codeFilename == null) {
755+
codeFilename = "None";
756+
}
750757
int codeFirstLineNo = this.getFirstLineNo() == 0 ? -1 : this.getFirstLineNo();
751758
return String.format("<code object %s, file \"%s\", line %d>", codeName, codeFilename, codeFirstLineNo);
752759
}

0 commit comments

Comments
 (0)