42
42
43
43
import static com .oracle .graal .python .builtins .PythonBuiltinClassType .IndexError ;
44
44
import static com .oracle .graal .python .builtins .PythonBuiltinClassType .MemoryError ;
45
+ import static com .oracle .graal .python .builtins .PythonBuiltinClassType .OverflowError ;
45
46
import static com .oracle .graal .python .builtins .PythonBuiltinClassType .RuntimeError ;
46
47
import static com .oracle .graal .python .builtins .PythonBuiltinClassType .StopIteration ;
47
48
import static com .oracle .graal .python .builtins .PythonBuiltinClassType .TypeError ;
@@ -179,6 +180,7 @@ PNone doGeneric(VirtualFrame frame, PDeque self, Object iterable, Object maxlenO
179
180
@ Cached CastToJavaIntExactNode castToIntNode ,
180
181
@ CachedLibrary (limit = "1" ) PythonObjectLibrary lib ,
181
182
@ Cached GetNextNode getNextNode ,
183
+ @ Cached IsBuiltinClassProfile isTypeErrorProfile ,
182
184
@ Cached IsBuiltinClassProfile isStopIterationProfile ) {
183
185
if (!PGuards .isPNone (maxlenObj )) {
184
186
try {
@@ -187,6 +189,10 @@ PNone doGeneric(VirtualFrame frame, PDeque self, Object iterable, Object maxlenO
187
189
throw raise (ValueError , "maxlen must be non-negative" );
188
190
}
189
191
self .setMaxLength (maxlen );
192
+ } catch (PException e ) {
193
+ // CastToJavaIntExactNode will throw a TypeError; we need to convert to OverflowError
194
+ e .expect (TypeError , isTypeErrorProfile );
195
+ throw raise (OverflowError , ErrorMessages .PYTHON_INT_TOO_LARGE_TO_CONV_TO , "int" );
190
196
} catch (CannotCastException e ) {
191
197
throw raise (TypeError , ErrorMessages .INTEGER_REQUIRED );
192
198
}
0 commit comments