Skip to content

Commit 2836b89

Browse files
committed
fix FunctionBuiltins: __truffle_source__ (methods allow arbitrary callables as functions)
1 parent c9293a2 commit 2836b89

File tree

1 file changed

+7
-4
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function

1 file changed

+7
-4
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/FunctionBuiltins.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,13 @@ Object doFunction(PFunction function) {
249249
}
250250

251251
@Specialization
252-
Object doMethod(PMethod function) {
253-
String sourceCode = function.getFunction().getSourceCode();
254-
if (sourceCode != null) {
255-
return sourceCode;
252+
Object doMethod(PMethod method) {
253+
Object function = method.getFunction();
254+
if (function instanceof PFunction) {
255+
String sourceCode = ((PFunction) function).getSourceCode();
256+
if (sourceCode != null) {
257+
return sourceCode;
258+
}
256259
}
257260
return PNone.NONE;
258261
}

0 commit comments

Comments
 (0)