Skip to content

Commit 2bb11a8

Browse files
qunaibitsteve-s
authored andcommitted
assure exception type is TypeError
1 parent 78125b5 commit 2bb11a8

File tree

1 file changed

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

1 file changed

+7
-4
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
import com.oracle.graal.python.nodes.attributes.LookupCallableSlotInMRONode;
6969
import com.oracle.graal.python.nodes.builtins.ListNodes.FastConstructListNode;
7070
import com.oracle.graal.python.nodes.call.special.CallVarargsMethodNode;
71+
import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile;
7172
import com.oracle.graal.python.nodes.object.GetClassNode;
7273
import com.oracle.graal.python.runtime.ExecutionContext.IndirectCallContext;
7374
import com.oracle.graal.python.runtime.PythonContext;
@@ -270,7 +271,8 @@ static ArrayBuilder<KeyValue> partialMergeFromSeq2(VirtualFrame frame, Object it
270271
@Cached FastConstructListNode createListNode,
271272
@Cached LenNode seqLenNode,
272273
@Cached PRaiseNode.Lazy raise,
273-
@Cached InlinedConditionProfile lengthTwoProfile) throws PException {
274+
@Cached InlinedConditionProfile lengthTwoProfile,
275+
@Cached IsBuiltinObjectProfile isTypeErrorProfile) throws PException {
274276
Object it = getIter.execute(frame, inliningTarget, iterable);
275277
ArrayBuilder<KeyValue> elements = new ArrayBuilder<>();
276278
Object next;
@@ -291,10 +293,11 @@ static ArrayBuilder<KeyValue> partialMergeFromSeq2(VirtualFrame frame, Object it
291293
elements.add(new KeyValue(key, value));
292294
}
293295
} catch (PException e) {
294-
if (lengthTwoProfile.profile(inliningTarget, len != 2)) {
295-
throw e;
296+
if (!lengthTwoProfile.profile(inliningTarget, len != 2) &&
297+
isTypeErrorProfile.profileException(inliningTarget, e, TypeError)) {
298+
throw raise.get(inliningTarget).raise(TypeError, ErrorMessages.CANNOT_CONVERT_DICT_UPDATE_SEQ, elements.size());
296299
}
297-
throw raise.get(inliningTarget).raise(TypeError, ErrorMessages.CANNOT_CONVERT_DICT_UPDATE_SEQ, elements.size());
300+
throw e;
298301
}
299302
return elements;
300303
}

0 commit comments

Comments
 (0)