@@ -800,7 +800,6 @@ Object execute(Object[] arguments,
800
800
@ Cached HPyAsPythonObjectNode asPythonObjectNode ,
801
801
@ Cached IsSubtypeNode isSubtypeNode ,
802
802
@ Cached FromCharPointerNode fromCharPointerNode ,
803
- @ Cached CastToJavaStringNode castToJavaStringNode ,
804
803
@ CachedLibrary (limit = "1" ) InteropLibrary interopLib ,
805
804
@ Cached CallNode callExceptionConstructorNode ,
806
805
@ Cached PRaiseNode raiseNode ,
@@ -816,23 +815,20 @@ Object execute(Object[] arguments,
816
815
return raiseNode .raise (SystemError , "exception %s not a BaseException subclass" , errTypeObj );
817
816
}
818
817
try {
818
+ Object valueObj ;
819
819
if (stringMode ) {
820
- Object valueObj = fromCharPointerNode .execute (arguments [2 ]);
821
- try {
822
- String errorMessage = castToJavaStringNode .execute (valueObj );
823
- throw raiseNode .raise (errTypeObj , errorMessage );
824
- } catch (CannotCastException e ) {
825
- throw raiseNode .raise (TypeError , "exception value is not a valid string" );
826
- }
820
+ valueObj = fromCharPointerNode .execute (arguments [2 ]);
827
821
} else {
828
- Object exception = callExceptionConstructorNode .execute (errTypeObj , asPythonObjectNode .execute (context , arguments [2 ]));
829
- if (PGuards .isPBaseException (exception )) {
830
- throw raiseNode .raiseExceptionObject ((PBaseException ) exception , langRef .get ());
831
- }
832
- // This should really not happen since we did a type check above but in theory,
833
- // the constructor could be broken.
834
- throw CompilerDirectives .shouldNotReachHere ();
822
+ valueObj = asPythonObjectNode .execute (context , arguments [2 ]);
835
823
}
824
+
825
+ Object exception = callExceptionConstructorNode .execute (errTypeObj , valueObj );
826
+ if (PGuards .isPBaseException (exception )) {
827
+ throw raiseNode .raiseExceptionObject ((PBaseException ) exception , langRef .get ());
828
+ }
829
+ // This should really not happen since we did a type check above but in theory,
830
+ // the constructor could be broken.
831
+ throw CompilerDirectives .shouldNotReachHere ();
836
832
} catch (PException p ) {
837
833
transformExceptionToNativeNode .execute (context , p );
838
834
return 0 ;
0 commit comments