Skip to content

Commit c98e84e

Browse files
committed
Fix NPE in AST interpreter code creation
1 parent 0a1c37c commit c98e84e

File tree

1 file changed

+8
-17
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code

1 file changed

+8
-17
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/CodeNodes.java

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,20 @@
4040
*/
4141
package com.oracle.graal.python.builtins.objects.code;
4242

43-
import static com.oracle.graal.python.nodes.truffle.TruffleStringMigrationPythonTypes.assertNoJavaString;
44-
45-
import java.util.ArrayList;
4643
import java.util.Arrays;
47-
import java.util.List;
4844

4945
import org.graalvm.polyglot.io.ByteSequence;
5046

5147
import com.oracle.graal.python.PythonLanguage;
5248
import com.oracle.graal.python.builtins.modules.MarshalModuleBuiltins;
5349
import com.oracle.graal.python.builtins.objects.function.Signature;
54-
import com.oracle.graal.python.builtins.objects.str.PString;
5550
import com.oracle.graal.python.compiler.CodeUnit;
5651
import com.oracle.graal.python.nodes.IndirectCallNode;
5752
import com.oracle.graal.python.nodes.PNodeWithContext;
5853
import com.oracle.graal.python.nodes.PRootNode;
5954
import com.oracle.graal.python.nodes.bytecode.PBytecodeGeneratorFunctionRootNode;
6055
import com.oracle.graal.python.nodes.bytecode.PBytecodeRootNode;
6156
import com.oracle.graal.python.nodes.util.BadOPCodeNode;
62-
import com.oracle.graal.python.nodes.util.CastToJavaStringNode;
6357
import com.oracle.graal.python.runtime.ExecutionContext.IndirectCallContext;
6458
import com.oracle.graal.python.runtime.PythonContext;
6559
import com.oracle.graal.python.runtime.PythonOptions;
@@ -186,18 +180,15 @@ public static PCode createCode(PythonContext context, int flags, byte[] codedata
186180
}
187181

188182
@TruffleBoundary
189-
private static String[] toStringArray(Object[] array) {
190-
List<String> list = new ArrayList<>(array.length);
191-
for (Object item : array) {
192-
item = assertNoJavaString(item);
193-
if (item instanceof TruffleString) {
194-
list.add(((TruffleString) item).toJavaStringUncached());
195-
}
196-
if (item instanceof PString) {
197-
list.add(CastToJavaStringNode.getUncached().execute(item));
198-
}
183+
private static String[] toStringArray(TruffleString[] array) {
184+
if (array == null) {
185+
return null;
186+
}
187+
String[] result = new String[array.length];
188+
for (int i = 0; i < array.length; i++) {
189+
result[i] = array[i].toJavaStringUncached();
199190
}
200-
return list.toArray(new String[list.size()]);
191+
return result;
201192
}
202193

203194
public static CreateCodeNode create() {

0 commit comments

Comments
 (0)