|
62 | 62 | import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes.ListGeneralizationNode;
|
63 | 63 | import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes.SetItemNode;
|
64 | 64 | import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes.SetItemScalarNode;
|
65 |
| -import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodesFactory.GetItemScalarNodeGen; |
66 | 65 | import com.oracle.graal.python.builtins.objects.tuple.PTuple;
|
67 | 66 | import com.oracle.graal.python.lib.PySliceNew;
|
68 | 67 | import com.oracle.graal.python.lib.PyTupleSizeNode;
|
@@ -136,7 +135,11 @@ abstract static class _PyTuple_SET_ITEM extends CApiTernaryBuiltinNode {
|
136 | 135 | int doManaged(PTuple tuple, long index, Object element,
|
137 | 136 | @Cached("createSetItem()") SequenceStorageNodes.SetItemNode setItemNode,
|
138 | 137 | @Cached ConditionProfile generalizedProfile) {
|
139 |
| - assert GetItemScalarNodeGen.getUncached().execute(tuple.getSequenceStorage(), (int) index) == null; |
| 138 | + // we cannot assume that there is nothing already in the tuple, because the API usage |
| 139 | + // is valid if the tuple has never been visible to Python code so far, and it is up to |
| 140 | + // the extension author to take care of correct decref's for the previously contained |
| 141 | + // elements. c.f. _testcapi.c#test_k_code where a tuple's element 0 is set multiple |
| 142 | + // times |
140 | 143 | SequenceStorage sequenceStorage = tuple.getSequenceStorage();
|
141 | 144 | checkBounds(sequenceStorage, index);
|
142 | 145 | SequenceStorage newStorage = setItemNode.execute(null, sequenceStorage, (int) index, element);
|
|
0 commit comments