Skip to content

Commit 8f614f6

Browse files
committed
Adopt GraalHPyErrSetString to new PRaiseNode interface
1 parent 6d0c6c0 commit 8f614f6

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContextFunctions.java

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,6 @@ Object execute(Object[] arguments,
800800
@Cached HPyAsPythonObjectNode asPythonObjectNode,
801801
@Cached IsSubtypeNode isSubtypeNode,
802802
@Cached FromCharPointerNode fromCharPointerNode,
803-
@Cached CastToJavaStringNode castToJavaStringNode,
804803
@CachedLibrary(limit = "1") InteropLibrary interopLib,
805804
@Cached CallNode callExceptionConstructorNode,
806805
@Cached PRaiseNode raiseNode,
@@ -816,23 +815,20 @@ Object execute(Object[] arguments,
816815
return raiseNode.raise(SystemError, "exception %s not a BaseException subclass", errTypeObj);
817816
}
818817
try {
818+
Object valueObj;
819819
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]);
827821
} 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]);
835823
}
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();
836832
} catch (PException p) {
837833
transformExceptionToNativeNode.execute(context, p);
838834
return 0;

0 commit comments

Comments
 (0)