Skip to content

Commit e43785f

Browse files
committed
guard against no closure
1 parent 9bdb52b commit e43785f

File tree

1 file changed

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

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ Object getCode(PFunction self, @SuppressWarnings("unused") PNone none) {
253253
@SuppressWarnings("unused")
254254
@Specialization
255255
Object setCode(PFunction self, PCode code) {
256-
int closureLength = self.getClosure().length;
256+
int closureLength = self.getClosure() == null ? 0 : self.getClosure().length;
257257
int freeVarsLength = code.getFreeVars().length;
258258
if (closureLength != freeVarsLength) {
259259
throw raise(PythonBuiltinClassType.ValueError, "%s() requires a code object with %d free vars, not %d", self.getName(), closureLength, freeVarsLength);

0 commit comments

Comments
 (0)