Skip to content

Commit 8fc5b7d

Browse files
committed
Fix readFromDict guard
1 parent a84deba commit 8fc5b7d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/attributes/ReadAttributeFromObjectNode.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
import com.oracle.graal.python.nodes.util.CannotCastException;
6363
import com.oracle.graal.python.nodes.util.CastToJavaStringNode;
6464
import com.oracle.graal.python.runtime.PythonOptions;
65+
import com.oracle.truffle.api.dsl.Bind;
6566
import com.oracle.truffle.api.dsl.Cached;
6667
import com.oracle.truffle.api.dsl.Cached.Shared;
6768
import com.oracle.truffle.api.dsl.GenerateUncached;
@@ -141,11 +142,14 @@ protected static Object readFromBuiltinModuleDict(PythonModule object, String ke
141142
}
142143

143144
// read from the Dict
144-
@Specialization(guards = "!isHiddenKey(key)", replaces = "readFromBuiltinModuleDict")
145+
@Specialization(guards = {
146+
"!isHiddenKey(key)",
147+
"dict != null"
148+
}, replaces = "readFromBuiltinModuleDict", limit = "1")
145149
protected static Object readFromDict(@SuppressWarnings("unused") PythonObject object, Object key,
146-
@Shared("getDict") @Cached GetDictIfExistsNode getDict,
150+
@Shared("getDict") @SuppressWarnings("unused") @Cached GetDictIfExistsNode getDict,
151+
@Bind("getDict.execute(object)") PDict dict,
147152
@Shared("hlib") @CachedLibrary(limit = "MAX_DICT_TYPES") HashingStorageLibrary hlib) {
148-
PDict dict = getDict.execute(object);
149153
if (dict == null) {
150154
return PNone.NO_VALUE;
151155
}

0 commit comments

Comments
 (0)