@@ -1037,20 +1037,26 @@ private static String getIndent(int indent) {
1037
1037
return PythonUtils .sbToString (sb );
1038
1038
}
1039
1039
1040
- void displaySourceLine (VirtualFrame frame , Object out , String fileName , int lineNo , int indent ) {
1040
+ @ TruffleBoundary
1041
+ CharSequence getSourceLine (String fileName , int lineNo ) {
1041
1042
final PythonContext context = getContext ();
1042
1043
TruffleFile file = context .getEnv ().getInternalTruffleFile (fileName );
1043
1044
final Source source ;
1044
1045
try {
1045
1046
source = PythonLanguage .newSource (context , file , fileName );
1046
- final CharSequence line = source .getCharacters (lineNo );
1047
- print (frame , out , getIndent (indent ));
1048
- print (frame , out , PythonUtils .trimLeft (line ));
1049
- print (frame , out , "\n " );
1050
- } catch (IOException ignored ) {
1047
+ return source .getCharacters (lineNo );
1048
+ } catch (IOException ioe ) {
1049
+ return null ;
1051
1050
}
1052
1051
}
1053
1052
1053
+ void displaySourceLine (VirtualFrame frame , Object out , String fileName , int lineNo , int indent ) {
1054
+ final CharSequence line = getSourceLine (fileName , lineNo );
1055
+ print (frame , out , getIndent (indent ));
1056
+ print (frame , out , PythonUtils .trimLeft (line ));
1057
+ print (frame , out , "\n " );
1058
+ }
1059
+
1054
1060
void printInternal (VirtualFrame frame , Object out , PTraceback traceback , long limit ) {
1055
1061
int depth = 0 ;
1056
1062
String lastFile = null ;
0 commit comments