@@ -543,8 +543,6 @@ protected TRegexCache getTRegexCache(Object pattern) {
543
543
544
544
abstract static class RECheckInputTypeNode extends PNodeWithRaise {
545
545
546
- private static final PTuple SUPPORTED_BINARY_INPUT_TYPES = PythonObjectFactory .getUncached ().createTuple (new Object []{PythonBuiltinClassType .PBytes , PythonBuiltinClassType .PByteArray ,
547
- PythonBuiltinClassType .PMMap , PythonBuiltinClassType .PMemoryView , PythonBuiltinClassType .PArray });
548
546
private static final TruffleString T_UNSUPPORTED_INPUT_TYPE = tsLiteral ("expected string or bytes-like object" );
549
547
private static final TruffleString T_UNEXPECTED_BYTES = tsLiteral ("cannot use a string pattern on a bytes-like object" );
550
548
private static final TruffleString T_UNEXPECTED_STR = tsLiteral ("cannot use a bytes pattern on a string-like object" );
@@ -554,12 +552,13 @@ abstract static class RECheckInputTypeNode extends PNodeWithRaise {
554
552
@ Specialization
555
553
protected void check (VirtualFrame frame , Object input , boolean expectBytes ,
556
554
@ Bind ("this" ) Node inliningTarget ,
555
+ @ Cached ("getSupportedBinaryInputTypes()" ) PTuple supportedBinaryInputTypes ,
557
556
@ Cached BuiltinFunctions .IsInstanceNode isStringNode ,
558
557
@ Cached BuiltinFunctions .IsInstanceNode isBytesNode ,
559
558
@ Cached InlinedConditionProfile unsupportedInputTypeProfile ,
560
559
@ Cached InlinedConditionProfile unexpectedInputTypeProfile ) {
561
560
boolean isString = (boolean ) isStringNode .execute (frame , input , PythonBuiltinClassType .PString );
562
- boolean isBytes = !isString && (boolean ) isBytesNode .execute (frame , input , SUPPORTED_BINARY_INPUT_TYPES );
561
+ boolean isBytes = !isString && (boolean ) isBytesNode .execute (frame , input , supportedBinaryInputTypes );
563
562
if (unsupportedInputTypeProfile .profile (inliningTarget , !isString && !isBytes )) {
564
563
throw getRaiseNode ().raise (TypeError , T_UNSUPPORTED_INPUT_TYPE );
565
564
}
@@ -571,6 +570,12 @@ protected void check(VirtualFrame frame, Object input, boolean expectBytes,
571
570
}
572
571
}
573
572
}
573
+
574
+ @ NeverDefault
575
+ protected PTuple getSupportedBinaryInputTypes () {
576
+ return PythonObjectFactory .getUncached ().createTuple (new Object []{PythonBuiltinClassType .PBytes , PythonBuiltinClassType .PByteArray , PythonBuiltinClassType .PMMap ,
577
+ PythonBuiltinClassType .PMemoryView , PythonBuiltinClassType .PArray });
578
+ }
574
579
}
575
580
576
581
abstract static class CreateMatchFromTRegexResultNode extends PNodeWithContext {
0 commit comments