Skip to content

Commit 78f2b6f

Browse files
committed
[GR-29753] Fix contract violations triggered in test_interop
1 parent 7a8bd7f commit 78f2b6f

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

graalpython/com.oracle.graal.python.test/src/tests/test_interop.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,6 @@ def test_remove():
160160
polyglot.__remove__(o, "@direct_field")
161161
assert not hasattr(o, "direct_field")
162162

163-
o["grrrr"] = 12
164-
polyglot.__remove__(o, "grrrr")
165-
assert "grrrr" not in list(o.keys())
166163

167164
def test_execute():
168165
assert polyglot.__execute__(abs, -10) == 10
@@ -251,7 +248,6 @@ def test_key_info():
251248

252249
assert polyglot.__key_info__(o, "__getattribute__", "readable")
253250
assert polyglot.__key_info__(o, "__getattribute__", "invokable")
254-
assert not polyglot.__key_info__(o, "__getattribute__", "modifiable")
255251
assert not polyglot.__key_info__(o, "__getattribute__", "removable")
256252
assert not polyglot.__key_info__(o, "__getattribute__", "insertable")
257253

@@ -268,12 +264,12 @@ def test_java_classpath():
268264
java.add_to_classpath(1)
269265
except TypeError as e:
270266
assert "classpath argument 1 must be string, not int" in str(e)
271-
267+
272268
try:
273269
java.add_to_classpath('a', 1)
274270
except TypeError as e:
275271
assert "classpath argument 2 must be string, not int" in str(e)
276-
272+
277273
def test_host_lookup():
278274
import java
279275
try:

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,6 +1496,14 @@ static int access(Object object, String fieldName,
14961496
if (!isImmutable.execute(owner)) {
14971497
info |= REMOVABLE;
14981498
info |= MODIFIABLE;
1499+
} else if (owner != object && (info & WRITE_SIDE_EFFECTS) == 0) {
1500+
// we already checked the owner to be immutable at this point, so we definitely
1501+
// cannot remove it (lookup will always lead to that not mutable owner). But if
1502+
// it's not a setter, we may still be able to write that attribute directly on
1503+
// the object
1504+
if (!isImmutable.execute(object)) {
1505+
info |= MODIFIABLE;
1506+
}
14991507
}
15001508
} else {
15011509
if (dataModelLibrary.isSequence(object) && isItemReadable(object, fieldName, getItemNode)) {

0 commit comments

Comments
 (0)