Skip to content

Commit 5921736

Browse files
horakivoelkorchi
authored andcommitted
Adjusting the delete from attribute to cover PythonBuiltinClass
(cherry picked from commit 054c3eb)
1 parent df5ca5e commit 5921736

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,8 @@ static boolean writeToDictClass(PythonClass klass, TruffleString key, Object val
230230
return writeToDictManagedClass(klass, dict, key, value, inliningTarget, callAttrUpdate, updateStorage, setHashingStorageItem, codePointLengthNode, codePointAtIndexNode);
231231
}
232232

233-
@Specialization(guards = {"dict != null", "isNoValue(value)"})
234-
static boolean deleteFromDict(PythonObject obj, TruffleString key, Object value,
233+
@Specialization(guards = {"dict != null", "isNoValue(value)", "!isPythonBuiltinClass(obj)"})
234+
static boolean deleteFromPythonObject(PythonObject obj, TruffleString key, Object value,
235235
@Bind("this") Node inliningTarget,
236236
@SuppressWarnings("unused") @Shared("getDict") @Cached GetDictIfExistsNode getDict,
237237
@Bind("getDict.execute(obj)") PDict dict,
@@ -252,6 +252,14 @@ static boolean deleteFromDict(PythonObject obj, TruffleString key, Object value,
252252
}
253253
}
254254

255+
@Specialization(guards = {"dict != null", "isNoValue(value)"})
256+
static boolean deleteFromPythonBuiltinClass(PythonBuiltinClass klass, TruffleString key, Object value,
257+
@Bind("this") Node inliningTarget,
258+
@SuppressWarnings("unused") @Shared("getDict") @Cached GetDictIfExistsNode getDict,
259+
@Bind("getDict.execute(klass)") PDict dict) {
260+
throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CANT_SET_ATTRIBUTE_R_OF_IMMUTABLE_TYPE_N, key, klass);
261+
}
262+
255263
private static boolean writeToDictManagedClass(PythonManagedClass klass, PDict dict, TruffleString key, Object value, Node inliningTarget,
256264
InlinedBranchProfile callAttrUpdate, InlinedBranchProfile updateStorage, HashingStorageSetItem setHashingStorageItem, TruffleString.CodePointLengthNode codePointLengthNode,
257265
TruffleString.CodePointAtIndexNode codePointAtIndexNode) {

0 commit comments

Comments
 (0)