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