@@ -587,14 +587,18 @@ Object run(PNone typ, PNone val, PNone tb) {
587587 }
588588
589589 @ 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 )));
592594 return PNone .NONE ;
593595 }
594596
595597 @ 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 )));
598602 return PNone .NONE ;
599603 }
600604 }
@@ -654,14 +658,17 @@ Object doClear(PNone typ, PNone val, PNone tb) {
654658 }
655659
656660 @ 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 )));
659665 return PNone .NONE ;
660666 }
661667
662668 @ 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 );
665672 }
666673
667674 @ Fallback
@@ -864,59 +871,65 @@ Object doNativeWrapper(String name, DynamicObjectNativeWrapper.PythonObjectNativ
864871
865872 @ Specialization (guards = "!isPythonObjectNativeWrapper(result)" )
866873 Object doPrimitiveWrapper (String name , @ SuppressWarnings ("unused" ) PythonNativeWrapper result ,
874+ @ Shared ("language" ) @ CachedLanguage PythonLanguage language ,
867875 @ Shared ("ctxt" ) @ CachedContext (PythonLanguage .class ) PythonContext context ,
868876 @ Shared ("fact" ) @ Cached PythonObjectFactory factory ,
869877 @ Shared ("raise" ) @ Cached PRaiseNode raise ) {
870- checkFunctionResult (name , false , false , context , raise , factory );
878+ checkFunctionResult (name , false , false , language , context , raise , factory );
871879 return result ;
872880 }
873881
874882 @ Specialization (guards = "isNoValue(result)" )
875883 Object doNoValue (String name , @ SuppressWarnings ("unused" ) PNone result ,
884+ @ Shared ("language" ) @ CachedLanguage PythonLanguage language ,
876885 @ Shared ("ctxt" ) @ CachedContext (PythonLanguage .class ) PythonContext context ,
877886 @ Shared ("fact" ) @ Cached PythonObjectFactory factory ,
878887 @ Shared ("raise" ) @ Cached PRaiseNode raise ) {
879- checkFunctionResult (name , true , false , context , raise , factory );
888+ checkFunctionResult (name , true , false , language , context , raise , factory );
880889 return PNone .NO_VALUE ;
881890 }
882891
883892 @ Specialization (guards = "!isNoValue(result)" )
884893 Object doPythonObject (String name , @ SuppressWarnings ("unused" ) PythonAbstractObject result ,
894+ @ Shared ("language" ) @ CachedLanguage PythonLanguage language ,
885895 @ Shared ("ctxt" ) @ CachedContext (PythonLanguage .class ) PythonContext context ,
886896 @ Shared ("fact" ) @ Cached PythonObjectFactory factory ,
887897 @ Shared ("raise" ) @ Cached PRaiseNode raise ) {
888- checkFunctionResult (name , false , false , context , raise , factory );
898+ checkFunctionResult (name , false , false , language , context , raise , factory );
889899 return result ;
890900 }
891901
892902 @ Specialization
893903 Object doPythonNativeNull (String name , @ SuppressWarnings ("unused" ) PythonNativeNull result ,
904+ @ Shared ("language" ) @ CachedLanguage PythonLanguage language ,
894905 @ Shared ("ctxt" ) @ CachedContext (PythonLanguage .class ) PythonContext context ,
895906 @ Shared ("fact" ) @ Cached PythonObjectFactory factory ,
896907 @ Shared ("raise" ) @ Cached PRaiseNode raise ) {
897- checkFunctionResult (name , true , false , context , raise , factory );
908+ checkFunctionResult (name , true , false , language , context , raise , factory );
898909 return result ;
899910 }
900911
901912 @ Specialization
902913 int doInteger (String name , int result ,
914+ @ Shared ("language" ) @ CachedLanguage PythonLanguage language ,
903915 @ Shared ("ctxt" ) @ CachedContext (PythonLanguage .class ) PythonContext context ,
904916 @ Shared ("fact" ) @ Cached PythonObjectFactory factory ,
905917 @ Shared ("raise" ) @ Cached PRaiseNode raise ) {
906918 // If the native functions returns a primitive int, only a value '-1' indicates an
907919 // error.
908- checkFunctionResult (name , result == -1 , true , context , raise , factory );
920+ checkFunctionResult (name , result == -1 , true , language , context , raise , factory );
909921 return result ;
910922 }
911923
912924 @ Specialization
913925 long doLong (String name , long result ,
926+ @ Shared ("language" ) @ CachedLanguage PythonLanguage language ,
914927 @ Shared ("ctxt" ) @ CachedContext (PythonLanguage .class ) PythonContext context ,
915928 @ Shared ("fact" ) @ Cached PythonObjectFactory factory ,
916929 @ Shared ("raise" ) @ Cached PRaiseNode raise ) {
917930 // If the native functions returns a primitive int, only a value '-1' indicates an
918931 // error.
919- checkFunctionResult (name , result == -1 , true , context , raise , factory );
932+ checkFunctionResult (name , result == -1 , true , language , context , raise , factory );
920933 return result ;
921934 }
922935
@@ -930,14 +943,16 @@ long doLong(String name, long result,
930943 Object doForeign (String name , Object result ,
931944 @ Exclusive @ Cached ("createBinaryProfile()" ) ConditionProfile isNullProfile ,
932945 @ Exclusive @ CachedLibrary (limit = "3" ) InteropLibrary lib ,
946+ @ Shared ("language" ) @ CachedLanguage PythonLanguage language ,
933947 @ Shared ("ctxt" ) @ CachedContext (PythonLanguage .class ) PythonContext context ,
934948 @ Shared ("fact" ) @ Cached PythonObjectFactory factory ,
935949 @ 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 );
937951 return result ;
938952 }
939953
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 ) {
941956 PException currentException = context .getCurrentException ();
942957 boolean errOccurred = currentException != null ;
943958 if (indicatesError ) {
@@ -953,7 +968,7 @@ private void checkFunctionResult(String name, boolean indicatesError, boolean is
953968 context .setCurrentException (null );
954969 PBaseException sysExc = factory .createBaseException (PythonErrorType .SystemError , ErrorMessages .RETURNED_RESULT_WITH_ERROR_SET , new Object []{name });
955970 sysExc .setCause (currentException .getEscapedException ());
956- throw PException .fromObject (sysExc , this );
971+ throw PException .fromObject (sysExc , this , PythonOptions . isPExceptionWithJavaStacktrace ( language ) );
957972 }
958973 }
959974
@@ -1570,7 +1585,8 @@ Object newFrame(Object threadState, PCode code, PythonObject globals, Object loc
15701585 abstract static class PyTraceBackHereNode extends PythonUnaryBuiltinNode {
15711586 @ Specialization
15721587 int tbHere (PFrame frame ,
1573- @ Cached GetTracebackNode getTracebackNode ) {
1588+ @ Cached GetTracebackNode getTracebackNode ,
1589+ @ CachedLanguage PythonLanguage language ) {
15741590 PythonContext context = getContext ();
15751591 PException currentException = context .getCurrentException ();
15761592 if (currentException != null ) {
@@ -1579,7 +1595,8 @@ int tbHere(PFrame frame,
15791595 traceback = getTracebackNode .execute (currentException .getTraceback ());
15801596 }
15811597 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 ));
15831600 }
15841601
15851602 return 0 ;
0 commit comments