@@ -99,6 +99,7 @@ static Object reconstructCached(VirtualFrame frame, Object arrayType, TruffleStr
99
99
@ Exclusive @ Cached PyObjectCallMethodObjArgs callDecode ,
100
100
@ Exclusive @ Cached ArrayBuiltins .FromBytesNode fromBytesNode ,
101
101
@ Exclusive @ Cached ArrayBuiltins .FromUnicodeNode fromUnicodeNode ,
102
+ @ Exclusive @ Cached TypeNodes .IsTypeNode isTypeNode ,
102
103
@ Exclusive @ Cached IsSubtypeNode isSubtypeNode ,
103
104
@ Exclusive @ Cached ArrayBuiltins .ByteSwapNode byteSwapNode ,
104
105
@ Exclusive @ Cached TruffleString .CodePointLengthNode lengthNode ,
@@ -109,7 +110,8 @@ static Object reconstructCached(VirtualFrame frame, Object arrayType, TruffleStr
109
110
if (format == null ) {
110
111
throw raiseNode .raise (inliningTarget , ValueError , ErrorMessages .BAD_TYPECODE );
111
112
}
112
- return doReconstruct (frame , inliningTarget , arrayType , typeCode , cachedCode , bytes , callDecode , fromBytesNode , fromUnicodeNode , isSubtypeNode , byteSwapNode , formatProfile .profile (format ),
113
+ return doReconstruct (frame , inliningTarget , arrayType , typeCode , cachedCode , bytes , callDecode , fromBytesNode , fromUnicodeNode , isTypeNode , isSubtypeNode , byteSwapNode ,
114
+ formatProfile .profile (format ),
113
115
getInstanceShape , raiseNode );
114
116
}
115
117
@@ -119,6 +121,7 @@ static Object reconstruct(VirtualFrame frame, Object arrayType, TruffleString ty
119
121
@ Exclusive @ Cached PyObjectCallMethodObjArgs callDecode ,
120
122
@ Exclusive @ Cached ArrayBuiltins .FromBytesNode fromBytesNode ,
121
123
@ Exclusive @ Cached ArrayBuiltins .FromUnicodeNode fromUnicodeNode ,
124
+ @ Exclusive @ Cached TypeNodes .IsTypeNode isTypeNode ,
122
125
@ Exclusive @ Cached IsSubtypeNode isSubtypeNode ,
123
126
@ Exclusive @ Cached ArrayBuiltins .ByteSwapNode byteSwapNode ,
124
127
@ Exclusive @ Cached TruffleString .CodePointLengthNode lengthNode ,
@@ -129,14 +132,18 @@ static Object reconstruct(VirtualFrame frame, Object arrayType, TruffleString ty
129
132
if (format == null ) {
130
133
throw raiseNode .raise (inliningTarget , ValueError , ErrorMessages .BAD_TYPECODE );
131
134
}
132
- return doReconstruct (frame , inliningTarget , arrayType , typeCode , mformatCode , bytes , callDecode , fromBytesNode , fromUnicodeNode , isSubtypeNode , byteSwapNode , format , getInstanceShape ,
135
+ return doReconstruct (frame , inliningTarget , arrayType , typeCode , mformatCode , bytes , callDecode , fromBytesNode , fromUnicodeNode , isTypeNode , isSubtypeNode , byteSwapNode , format ,
136
+ getInstanceShape ,
133
137
raiseNode );
134
138
}
135
139
136
140
private static Object doReconstruct (VirtualFrame frame , Node inliningTarget , Object arrayType , TruffleString typeCode , int mformatCode , PBytes bytes , PyObjectCallMethodObjArgs callDecode ,
137
- ArrayBuiltins .FromBytesNode fromBytesNode , ArrayBuiltins .FromUnicodeNode fromUnicodeNode , IsSubtypeNode isSubtypeNode ,
141
+ ArrayBuiltins .FromBytesNode fromBytesNode , ArrayBuiltins .FromUnicodeNode fromUnicodeNode , TypeNodes . IsTypeNode isTypeNode , IsSubtypeNode isSubtypeNode ,
138
142
ArrayBuiltins .ByteSwapNode byteSwapNode , BufferFormat format ,
139
143
TypeNodes .GetInstanceShape getInstanceShape , PRaiseNode raiseNode ) {
144
+ if (!isTypeNode .execute (inliningTarget , arrayType )) {
145
+ throw raiseNode .raise (inliningTarget , TypeError , ErrorMessages .FIRST_ARGUMENT_MUST_BE_A_TYPE_OBJECT_NOT_P , arrayType );
146
+ }
140
147
if (!isSubtypeNode .execute (arrayType , PythonBuiltinClassType .PArray )) {
141
148
throw raiseNode .raise (inliningTarget , TypeError , ErrorMessages .N_NOT_SUBTYPE_OF_ARRAY , arrayType );
142
149
}
0 commit comments