Skip to content

Commit 6254cd6

Browse files
committed
fix creation of dict from dict and kwargs, when storage is unmodifiable (of the src dict)
1 parent cd641e7 commit 6254cd6

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,15 @@ public void doPDict(PDict self, PDict iterable, @SuppressWarnings("unused") PKey
301301
}
302302

303303
@Specialization(guards = {"!isNoValue(iterable)", "!isEmpty(kwargs)"})
304-
public void doPDictKwargs(PDict self, PDict iterable, PKeyword[] kwargs) {
305-
HashingStorage dictStorage = iterable.getDictStorage().copy(HashingStorage.DEFAULT_EQIVALENCE);
306-
dictStorage.addAll(new KeywordsStorage(kwargs));
304+
public void doPDictKwargs(PDict self, PDict iterable, PKeyword[] kwargs,
305+
@Cached("create()") UnionNode unionNode) {
306+
HashingStorage dictStorage;
307+
try {
308+
dictStorage = iterable.getDictStorage().copy(HashingStorage.DEFAULT_EQIVALENCE);
309+
dictStorage.addAll(new KeywordsStorage(kwargs));
310+
} catch (HashingStorage.UnmodifiableStorageException e) {
311+
dictStorage = unionNode.execute(iterable.getDictStorage(), new KeywordsStorage(kwargs));
312+
}
307313
self.setDictStorage(dictStorage);
308314
}
309315

0 commit comments

Comments
 (0)