1
1
/*
2
- * Copyright (c) 2017, 2021 , Oracle and/or its affiliates.
2
+ * Copyright (c) 2017, 2022 , Oracle and/or its affiliates.
3
3
* Copyright (c) 2013, Regents of the University of California
4
4
*
5
5
* All rights reserved.
@@ -85,6 +85,10 @@ public static GetItemNode create(ExpressionNode primary, ExpressionNode slice) {
85
85
return GetItemNodeGen .create (primary , slice );
86
86
}
87
87
88
+ protected LookupAndCallBinaryNode createLookupAndCallGetItemNode () {
89
+ return LookupAndCallBinaryNode .create (SpecialMethodSlot .GetItem );
90
+ }
91
+
88
92
@ Override
89
93
public StatementNode makeWriteNode (ExpressionNode rhs ) {
90
94
return SetItemNode .create (getPrimary (), getSlice (), rhs );
@@ -101,9 +105,10 @@ Object doBuiltinList(VirtualFrame frame, PList primary, Object index,
101
105
@ SuppressWarnings ("unused" )
102
106
@ Specialization (guards = {"!indexCheckNode.execute(index)" , "!isPSlice(index)" }, limit = "1" )
103
107
public Object doListError (VirtualFrame frame , PList primary , Object index ,
108
+ @ Cached ("createLookupAndCallGetItemNode()" ) LookupAndCallBinaryNode lookupAndCallGetItem ,
104
109
@ SuppressWarnings ("unused" ) @ Cached PyIndexCheckNode indexCheckNode ,
105
110
@ Cached PRaiseNode raiseNode ) {
106
- throw raiseNode . raise ( TypeError , ErrorMessages . OBJ_INDEX_MUST_BE_INT_OR_SLICES , "list" , index );
111
+ return lookupAndCallGetItem . executeObject ( frame , primary , index );
107
112
}
108
113
109
114
@ Specialization (guards = {"indexCheckNode.execute(index) || isPSlice(index)" , "isBuiltinTuple.profileIsAnyBuiltinObject(primary)" }, limit = "1" )
0 commit comments