@@ -587,16 +587,18 @@ Object run(PNone typ, PNone val, PNone tb) {
587
587
}
588
588
589
589
@ Specialization
590
- Object run (@ SuppressWarnings ("unused" ) Object typ , PBaseException val , @ SuppressWarnings ("unused" ) PNone tb ) {
590
+ Object run (@ SuppressWarnings ("unused" ) Object typ , PBaseException val , @ SuppressWarnings ("unused" ) PNone tb ,
591
+ @ Shared ("language" ) @ CachedLanguage PythonLanguage language ) {
591
592
PythonContext context = getContext ();
592
- context .setCurrentException (PException .fromExceptionInfo (val , (LazyTraceback ) null , context . getOption ( PythonOptions .WithJavaStacktrace )));
593
+ context .setCurrentException (PException .fromExceptionInfo (val , (LazyTraceback ) null , PythonOptions .isPExceptionWithJavaStacktrace ( language )));
593
594
return PNone .NONE ;
594
595
}
595
596
596
597
@ Specialization
597
- Object run (@ SuppressWarnings ("unused" ) Object typ , PBaseException val , PTraceback tb ) {
598
+ Object run (@ SuppressWarnings ("unused" ) Object typ , PBaseException val , PTraceback tb ,
599
+ @ Shared ("language" ) @ CachedLanguage PythonLanguage language ) {
598
600
PythonContext context = getContext ();
599
- context .setCurrentException (PException .fromExceptionInfo (val , tb , context . getOption ( PythonOptions .WithJavaStacktrace )));
601
+ context .setCurrentException (PException .fromExceptionInfo (val , tb , PythonOptions .isPExceptionWithJavaStacktrace ( language )));
600
602
return PNone .NONE ;
601
603
}
602
604
}
@@ -656,15 +658,17 @@ Object doClear(PNone typ, PNone val, PNone tb) {
656
658
}
657
659
658
660
@ Specialization
659
- Object doFull (@ SuppressWarnings ("unused" ) Object typ , PBaseException val , PTraceback tb ) {
661
+ Object doFull (@ SuppressWarnings ("unused" ) Object typ , PBaseException val , PTraceback tb ,
662
+ @ Shared ("language" ) @ CachedLanguage PythonLanguage language ) {
660
663
PythonContext context = getContext ();
661
- context .setCaughtException (PException .fromExceptionInfo (val , tb , context . getOption ( PythonOptions .WithJavaStacktrace )));
664
+ context .setCaughtException (PException .fromExceptionInfo (val , tb , PythonOptions .isPExceptionWithJavaStacktrace ( language )));
662
665
return PNone .NONE ;
663
666
}
664
667
665
668
@ Specialization
666
- Object doWithoutTraceback (@ SuppressWarnings ("unused" ) Object typ , PBaseException val , @ SuppressWarnings ("unused" ) PNone tb ) {
667
- return doFull (typ , val , null );
669
+ Object doWithoutTraceback (@ SuppressWarnings ("unused" ) Object typ , PBaseException val , @ SuppressWarnings ("unused" ) PNone tb ,
670
+ @ Shared ("language" ) @ CachedLanguage PythonLanguage language ) {
671
+ return doFull (typ , val , null , language );
668
672
}
669
673
670
674
@ Fallback
@@ -867,59 +871,65 @@ Object doNativeWrapper(String name, DynamicObjectNativeWrapper.PythonObjectNativ
867
871
868
872
@ Specialization (guards = "!isPythonObjectNativeWrapper(result)" )
869
873
Object doPrimitiveWrapper (String name , @ SuppressWarnings ("unused" ) PythonNativeWrapper result ,
874
+ @ Shared ("language" ) @ CachedLanguage PythonLanguage language ,
870
875
@ Shared ("ctxt" ) @ CachedContext (PythonLanguage .class ) PythonContext context ,
871
876
@ Shared ("fact" ) @ Cached PythonObjectFactory factory ,
872
877
@ Shared ("raise" ) @ Cached PRaiseNode raise ) {
873
- checkFunctionResult (name , false , false , context , raise , factory );
878
+ checkFunctionResult (name , false , false , language , context , raise , factory );
874
879
return result ;
875
880
}
876
881
877
882
@ Specialization (guards = "isNoValue(result)" )
878
883
Object doNoValue (String name , @ SuppressWarnings ("unused" ) PNone result ,
884
+ @ Shared ("language" ) @ CachedLanguage PythonLanguage language ,
879
885
@ Shared ("ctxt" ) @ CachedContext (PythonLanguage .class ) PythonContext context ,
880
886
@ Shared ("fact" ) @ Cached PythonObjectFactory factory ,
881
887
@ Shared ("raise" ) @ Cached PRaiseNode raise ) {
882
- checkFunctionResult (name , true , false , context , raise , factory );
888
+ checkFunctionResult (name , true , false , language , context , raise , factory );
883
889
return PNone .NO_VALUE ;
884
890
}
885
891
886
892
@ Specialization (guards = "!isNoValue(result)" )
887
893
Object doPythonObject (String name , @ SuppressWarnings ("unused" ) PythonAbstractObject result ,
894
+ @ Shared ("language" ) @ CachedLanguage PythonLanguage language ,
888
895
@ Shared ("ctxt" ) @ CachedContext (PythonLanguage .class ) PythonContext context ,
889
896
@ Shared ("fact" ) @ Cached PythonObjectFactory factory ,
890
897
@ Shared ("raise" ) @ Cached PRaiseNode raise ) {
891
- checkFunctionResult (name , false , false , context , raise , factory );
898
+ checkFunctionResult (name , false , false , language , context , raise , factory );
892
899
return result ;
893
900
}
894
901
895
902
@ Specialization
896
903
Object doPythonNativeNull (String name , @ SuppressWarnings ("unused" ) PythonNativeNull result ,
904
+ @ Shared ("language" ) @ CachedLanguage PythonLanguage language ,
897
905
@ Shared ("ctxt" ) @ CachedContext (PythonLanguage .class ) PythonContext context ,
898
906
@ Shared ("fact" ) @ Cached PythonObjectFactory factory ,
899
907
@ Shared ("raise" ) @ Cached PRaiseNode raise ) {
900
- checkFunctionResult (name , true , false , context , raise , factory );
908
+ checkFunctionResult (name , true , false , language , context , raise , factory );
901
909
return result ;
902
910
}
903
911
904
912
@ Specialization
905
913
int doInteger (String name , int result ,
914
+ @ Shared ("language" ) @ CachedLanguage PythonLanguage language ,
906
915
@ Shared ("ctxt" ) @ CachedContext (PythonLanguage .class ) PythonContext context ,
907
916
@ Shared ("fact" ) @ Cached PythonObjectFactory factory ,
908
917
@ Shared ("raise" ) @ Cached PRaiseNode raise ) {
909
918
// If the native functions returns a primitive int, only a value '-1' indicates an
910
919
// error.
911
- checkFunctionResult (name , result == -1 , true , context , raise , factory );
920
+ checkFunctionResult (name , result == -1 , true , language , context , raise , factory );
912
921
return result ;
913
922
}
914
923
915
924
@ Specialization
916
925
long doLong (String name , long result ,
926
+ @ Shared ("language" ) @ CachedLanguage PythonLanguage language ,
917
927
@ Shared ("ctxt" ) @ CachedContext (PythonLanguage .class ) PythonContext context ,
918
928
@ Shared ("fact" ) @ Cached PythonObjectFactory factory ,
919
929
@ Shared ("raise" ) @ Cached PRaiseNode raise ) {
920
930
// If the native functions returns a primitive int, only a value '-1' indicates an
921
931
// error.
922
- checkFunctionResult (name , result == -1 , true , context , raise , factory );
932
+ checkFunctionResult (name , result == -1 , true , language , context , raise , factory );
923
933
return result ;
924
934
}
925
935
@@ -933,14 +943,16 @@ long doLong(String name, long result,
933
943
Object doForeign (String name , Object result ,
934
944
@ Exclusive @ Cached ("createBinaryProfile()" ) ConditionProfile isNullProfile ,
935
945
@ Exclusive @ CachedLibrary (limit = "3" ) InteropLibrary lib ,
946
+ @ Shared ("language" ) @ CachedLanguage PythonLanguage language ,
936
947
@ Shared ("ctxt" ) @ CachedContext (PythonLanguage .class ) PythonContext context ,
937
948
@ Shared ("fact" ) @ Cached PythonObjectFactory factory ,
938
949
@ Shared ("raise" ) @ Cached PRaiseNode raise ) {
939
- checkFunctionResult (name , isNullProfile .profile (lib .isNull (result )), false , context , raise , factory );
950
+ checkFunctionResult (name , isNullProfile .profile (lib .isNull (result )), false , language , context , raise , factory );
940
951
return result ;
941
952
}
942
953
943
- private void checkFunctionResult (String name , boolean indicatesError , boolean isPrimitiveResult , PythonContext context , PRaiseNode raise , PythonObjectFactory factory ) {
954
+ private void checkFunctionResult (String name , boolean indicatesError , boolean isPrimitiveResult , PythonLanguage language , PythonContext context , PRaiseNode raise ,
955
+ PythonObjectFactory factory ) {
944
956
PException currentException = context .getCurrentException ();
945
957
boolean errOccurred = currentException != null ;
946
958
if (indicatesError ) {
@@ -956,7 +968,7 @@ private void checkFunctionResult(String name, boolean indicatesError, boolean is
956
968
context .setCurrentException (null );
957
969
PBaseException sysExc = factory .createBaseException (PythonErrorType .SystemError , ErrorMessages .RETURNED_RESULT_WITH_ERROR_SET , new Object []{name });
958
970
sysExc .setCause (currentException .getEscapedException ());
959
- throw PException .fromObject (sysExc , this , context . getOption ( PythonOptions .WithJavaStacktrace ));
971
+ throw PException .fromObject (sysExc , this , PythonOptions .isPExceptionWithJavaStacktrace ( language ));
960
972
}
961
973
}
962
974
@@ -1573,7 +1585,8 @@ Object newFrame(Object threadState, PCode code, PythonObject globals, Object loc
1573
1585
abstract static class PyTraceBackHereNode extends PythonUnaryBuiltinNode {
1574
1586
@ Specialization
1575
1587
int tbHere (PFrame frame ,
1576
- @ Cached GetTracebackNode getTracebackNode ) {
1588
+ @ Cached GetTracebackNode getTracebackNode ,
1589
+ @ CachedLanguage PythonLanguage language ) {
1577
1590
PythonContext context = getContext ();
1578
1591
PException currentException = context .getCurrentException ();
1579
1592
if (currentException != null ) {
@@ -1582,7 +1595,8 @@ int tbHere(PFrame frame,
1582
1595
traceback = getTracebackNode .execute (currentException .getTraceback ());
1583
1596
}
1584
1597
PTraceback newTraceback = factory ().createTraceback (frame , frame .getLine (), traceback );
1585
- context .setCurrentException (PException .fromExceptionInfo (currentException .getExceptionObject (), newTraceback , context .getOption (PythonOptions .WithJavaStacktrace )));
1598
+ boolean withJavaStacktrace = PythonOptions .isPExceptionWithJavaStacktrace (language );
1599
+ context .setCurrentException (PException .fromExceptionInfo (currentException .getExceptionObject (), newTraceback , withJavaStacktrace ));
1586
1600
}
1587
1601
1588
1602
return 0 ;
0 commit comments