Skip to content

Commit 2c0cc8b

Browse files
committed
[GR-21141] dict with modifying __eq__ fix
PullRequest: graalpython/850
2 parents beaa247 + dbcf959 commit 2c0cc8b

File tree

6 files changed

+568
-127
lines changed

6 files changed

+568
-127
lines changed

graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_dict.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*DictTest.test_dictview_set_operations_on_keys
1414
*DictTest.test_empty_presized_dict_in_freelist
1515
*DictTest.test_eq
16+
*DictTest.test_equal_operator_modifying_operand
1617
*DictTest.test_errors_in_view_containment_check
1718
*DictTest.test_fromkeys_operator_modifying_dict_operand
1819
*DictTest.test_fromkeys_operator_modifying_set_operand

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/EconomicMapStorage.java

Lines changed: 198 additions & 57 deletions
Large diffs are not rendered by default.

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/HashingStorageLibrary.java

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ public int compareKeys(HashingStorage self, HashingStorage other) {
249249
*/
250250
public int compareEntriesWithState(HashingStorage self, HashingStorage other, ThreadState state) {
251251
if (state == null) {
252-
throw new AbstractMethodError("HashingStorageLibrary.compareKeysWithState");
252+
throw new AbstractMethodError("HashingStorageLibrary.compareEntriesWithState");
253253
}
254254
return compareEntries(self, other);
255255
}
@@ -264,7 +264,19 @@ public int compareEntries(HashingStorage self, HashingStorage other) {
264264
/**
265265
* @return the intersection of the two storages, keeping the values from {@code other}.
266266
*/
267-
public abstract HashingStorage intersect(HashingStorage self, HashingStorage other);
267+
public HashingStorage intersectWithState(HashingStorage self, HashingStorage other, ThreadState state) {
268+
if (state == null) {
269+
throw new AbstractMethodError("HashingStorageLibrary.intersectWithState");
270+
}
271+
return intersect(self, other);
272+
}
273+
274+
/**
275+
* @see #intersectWithState(HashingStorage, HashingStorage, ThreadState)
276+
*/
277+
public HashingStorage intersect(HashingStorage self, HashingStorage other) {
278+
return intersectWithState(self, other, null);
279+
}
268280

269281
/**
270282
* @return the xor of the two storages.
@@ -280,7 +292,19 @@ public int compareEntries(HashingStorage self, HashingStorage other) {
280292
/**
281293
* @return the a storage with all keys of {@code self} that are not also in {@code other}
282294
*/
283-
public abstract HashingStorage diff(HashingStorage self, HashingStorage other);
295+
public HashingStorage diffWithState(HashingStorage self, HashingStorage other, ThreadState state) {
296+
if (state == null) {
297+
throw new AbstractMethodError("HashingStorageLibrary.diffWithState");
298+
}
299+
return diff(self, other);
300+
}
301+
302+
/**
303+
* @see #diffWithState(HashingStorage, HashingStorage, ThreadState)
304+
*/
305+
public HashingStorage diff(HashingStorage self, HashingStorage other) {
306+
return diffWithState(self, other, null);
307+
}
284308

285309
/**
286310
* This method can be used to iterate over the keys of a store. Due to the nature of Java

0 commit comments

Comments
 (0)