Skip to content

Commit b58e805

Browse files
committed
covert decoded bytes to TruffleString
1 parent ea17f2a commit b58e805

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,6 +1416,7 @@ Object execute(Object[] arguments,
14161416
@Cached HPyAsHandleNode asHandleNode,
14171417
@Cached CastToJavaLongExactNode castToJavaLongNode,
14181418
@Cached GetByteArrayNode getByteArrayNode,
1419+
@Cached TruffleString.FromJavaStringNode fromJavaStringNode,
14191420
@Exclusive @Cached GilNode gil) throws ArityException {
14201421
boolean mustRelease = gil.acquire();
14211422
try {
@@ -1432,7 +1433,7 @@ Object execute(Object[] arguments,
14321433
} catch (OverflowException | InteropException ex) {
14331434
throw CompilerDirectives.shouldNotReachHere(ex);
14341435
}
1435-
String result = decode(CodingErrorAction.IGNORE, bytes);
1436+
TruffleString result = fromJavaStringNode.execute(decode(CodingErrorAction.IGNORE, bytes), TS_ENCODING);
14361437
return asHandleNode.execute(context, result);
14371438
} finally {
14381439
gil.release(mustRelease);
@@ -1472,6 +1473,7 @@ Object execute(Object[] arguments,
14721473
@Cached HPyAsHandleNode asHandleNode,
14731474
@Cached CastToJavaLongExactNode castToJavaLongNode,
14741475
@Cached CastToTruffleStringNode castToJavaStringNode,
1476+
@Cached TruffleString.FromJavaStringNode fromJavaStringNode,
14751477
@Cached GetByteArrayNode getByteArrayNode,
14761478
@Cached HPyRaiseNode raiseNode,
14771479
@Cached TruffleString.EqualNode equalNode,
@@ -1495,7 +1497,7 @@ Object execute(Object[] arguments,
14951497
// short-circuit the error reading etc
14961498
TruffleString errors = castToJavaStringNode.execute(callHPyFunction.call(context, GraalHPyNativeSymbol.POLYGLOT_FROM_STRING, arguments[3], "ascii"));
14971499
CodingErrorAction errorAction = CodecsModuleBuiltins.convertCodingErrorAction(errors, equalNode);
1498-
String result = decode(errorAction, bytes);
1500+
TruffleString result = fromJavaStringNode.execute(decode(errorAction, bytes), TS_ENCODING);
14991501
if (result == null) {
15001502
// TODO: refactor helper nodes for CodecsModuleBuiltins to use them here
15011503
return raiseNode.raiseWithoutFrame(context, GraalHPyHandle.NULL_HANDLE, PythonBuiltinClassType.UnicodeDecodeError, ErrorMessages.MALFORMED_INPUT);

0 commit comments

Comments
 (0)