Skip to content

Commit 78125b5

Browse files
qunaibitsteve-s
authored andcommitted
avoid overriding an exception
1 parent 7027c90 commit 78125b5

File tree

1 file changed

+5
-1
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,13 +274,14 @@ static ArrayBuilder<KeyValue> partialMergeFromSeq2(VirtualFrame frame, Object it
274274
Object it = getIter.execute(frame, inliningTarget, iterable);
275275
ArrayBuilder<KeyValue> elements = new ArrayBuilder<>();
276276
Object next;
277+
int len = 2;
277278
try {
278279
while ((next = nextNode.execute(frame, it)) != null) {
279280
PSequence element = createListNode.execute(frame, inliningTarget, next);
280281
assert element != null;
281282
// This constructs a new list using the builtin type. So, the object cannot
282283
// be subclassed and we can directly call 'len()'.
283-
int len = seqLenNode.execute(inliningTarget, element);
284+
len = seqLenNode.execute(inliningTarget, element);
284285

285286
if (lengthTwoProfile.profile(inliningTarget, len != 2)) {
286287
throw raise.get(inliningTarget).raise(ValueError, ErrorMessages.DICT_UPDATE_SEQ_ELEM_HAS_LENGTH_2_REQUIRED, elements.size(), len);
@@ -290,6 +291,9 @@ static ArrayBuilder<KeyValue> partialMergeFromSeq2(VirtualFrame frame, Object it
290291
elements.add(new KeyValue(key, value));
291292
}
292293
} catch (PException e) {
294+
if (lengthTwoProfile.profile(inliningTarget, len != 2)) {
295+
throw e;
296+
}
293297
throw raise.get(inliningTarget).raise(TypeError, ErrorMessages.CANNOT_CONVERT_DICT_UPDATE_SEQ, elements.size());
294298
}
295299
return elements;

0 commit comments

Comments
 (0)