Skip to content

Commit b123dc9

Browse files
committed
Fix: 'LocalsStorage.hasKey' must also check value.
1 parent 87ade01 commit b123dc9

File tree

1 file changed

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

1 file changed

+3
-1
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/LocalsStorage.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ public boolean hasKey(Object key, Equivalence eq) {
118118
if (!FrameSlotIDs.isUserFrameSlot(key)) {
119119
return false;
120120
}
121-
return frame.getFrameDescriptor().findFrameSlot(key) != null;
121+
// Deleting variables from a frame means to write 'null' into the slot. So we also need to
122+
// check the value.
123+
return frame.getFrameDescriptor().findFrameSlot(key) != null && getItem(key, eq) != null;
122124
}
123125

124126
@Override

0 commit comments

Comments
 (0)