@@ -2906,7 +2906,7 @@ _check_for_legacy_statements(PySyntaxErrorObject *self, Py_ssize_t start)
2906
2906
*/
2907
2907
static PyObject * print_prefix = NULL ;
2908
2908
static PyObject * exec_prefix = NULL ;
2909
- Py_ssize_t text_len = PyUnicode_GET_LENGTH (self -> text );
2909
+ Py_ssize_t text_len = PyUnicode_GET_LENGTH (self -> text ), match ;
2910
2910
int kind = PyUnicode_KIND (self -> text );
2911
2911
void * data = PyUnicode_DATA (self -> text );
2912
2912
@@ -2929,9 +2929,12 @@ _check_for_legacy_statements(PySyntaxErrorObject *self, Py_ssize_t start)
2929
2929
return -1 ;
2930
2930
}
2931
2931
}
2932
- if (PyUnicode_Tailmatch (self -> text , print_prefix ,
2933
- start , text_len , -1 )) {
2934
-
2932
+ match = PyUnicode_Tailmatch (self -> text , print_prefix ,
2933
+ start , text_len , -1 );
2934
+ if (match == -1 ) {
2935
+ return -1 ;
2936
+ }
2937
+ if (match ) {
2935
2938
return _set_legacy_print_statement_msg (self , start );
2936
2939
}
2937
2940
@@ -2942,10 +2945,17 @@ _check_for_legacy_statements(PySyntaxErrorObject *self, Py_ssize_t start)
2942
2945
return -1 ;
2943
2946
}
2944
2947
}
2945
- if (PyUnicode_Tailmatch (self -> text , exec_prefix ,
2946
- start , text_len , -1 )) {
2947
- Py_XSETREF (self -> msg ,
2948
- PyUnicode_FromString ("Missing parentheses in call to 'exec'" ));
2948
+ match = PyUnicode_Tailmatch (self -> text , exec_prefix , start , text_len , -1 );
2949
+ if (match == -1 ) {
2950
+ return -1 ;
2951
+ }
2952
+ if (match ) {
2953
+ PyObject * msg = PyUnicode_FromString ("Missing parentheses in call "
2954
+ "to 'exec'" );
2955
+ if (msg == NULL ) {
2956
+ return -1 ;
2957
+ }
2958
+ Py_XSETREF (self -> msg , msg );
2949
2959
return 1 ;
2950
2960
}
2951
2961
/* Fall back to the default error message */
0 commit comments