@@ -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