@@ -157,7 +157,11 @@ public void checkSyntaxErrorMessageContains(String source, String expectedMessag
157157 parse (source , name .getMethodName (), PythonParser .ParserMode .File );
158158 } catch (PException e ) {
159159 thrown = isSyntaxError (e );
160- Assert .assertTrue ("The expected message:\n \" " + expectedMessage + "\" \n was not found in\n \" " + e .getMessage () + "\" " , e .getMessage ().contains (expectedMessage ));
160+ InteropLibrary interop = InteropLibrary .getUncached ();
161+ Object exceptionMessageObject = interop .getExceptionMessage (e );
162+ Assert .assertTrue (interop .isString (exceptionMessageObject ));
163+ String exceptionMessage = interop .asString (exceptionMessageObject );
164+ Assert .assertTrue ("The expected message:\n \" " + expectedMessage + "\" \n was not found in\n \" " + exceptionMessage + "\" " , exceptionMessage .contains (expectedMessage ));
161165 }
162166
163167 assertTrue ("Expected SyntaxError was not thrown." , thrown );
@@ -169,7 +173,10 @@ public void checkSyntaxErrorMessage(String source, String expectedMessage) throw
169173 parse (source , name .getMethodName (), PythonParser .ParserMode .File );
170174 } catch (PException e ) {
171175 thrown = isSyntaxError (e );
172- Assert .assertEquals (expectedMessage , e .getMessage ());
176+ InteropLibrary interop = InteropLibrary .getUncached ();
177+ Object exceptionMessage = interop .getExceptionMessage (e );
178+ Assert .assertTrue (interop .isString (exceptionMessage ));
179+ Assert .assertEquals (expectedMessage , interop .asString (exceptionMessage ));
173180 }
174181
175182 assertTrue ("Expected SyntaxError was not thrown." , thrown );
0 commit comments