Skip to content

Commit 5a285bb

Browse files
committed
objects with *set_attr slots is not immutable
1 parent 4bd6370 commit 5a285bb

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/PythonAbstractObject.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,13 +1264,16 @@ public abstract static class IsImmutable extends Node {
12641264

12651265
@Specialization
12661266
public static boolean isImmutable(Node inliningTarget, Object object,
1267+
@Cached GetObjectSlotsNode getSlotsNode,
12671268
@Cached GetClassNode getClassNode) {
12681269
// TODO(fa) The first condition is too general; we should check if the object's type is
12691270
// 'type'
12701271
if (object instanceof PythonBuiltinClass || object instanceof PythonBuiltinObject || PGuards.isNativeClass(object) || PGuards.isNativeObject(object)) {
12711272
return true;
12721273
} else if (object instanceof PythonClass || object instanceof PythonModule) {
12731274
return false;
1275+
} else if (getSlotsNode.execute(inliningTarget, object).combined_tp_setattro_setattr() != null) {
1276+
return false;
12741277
} else {
12751278
Object klass = getClassNode.execute(inliningTarget, object);
12761279
return klass instanceof PythonBuiltinClassType || klass instanceof PythonBuiltinClass || PGuards.isNativeClass(object);

0 commit comments

Comments
 (0)