Skip to content

Commit 3aca45b

Browse files
committed
Initialize the tuple in PyStructSequence_New
1 parent 07c75e2 commit 3aca45b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextStructSeqBuiltins.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import static com.oracle.graal.python.util.PythonUtils.EMPTY_OBJECT_ARRAY;
5454

5555
import java.util.ArrayList;
56+
import java.util.Arrays;
5657

5758
import com.oracle.graal.python.PythonLanguage;
5859
import com.oracle.graal.python.builtins.PythonBuiltinClassType;
@@ -175,7 +176,9 @@ static Object doGeneric(Object cls,
175176
throw raiseNode.get(inliningTarget).raise(SystemError, ErrorMessages.BAD_ARG_TO_INTERNAL_FUNC, EMPTY_OBJECT_ARRAY);
176177
} else {
177178
int realSize = castToIntNode.execute(inliningTarget, realSizeObj);
178-
return factory.createTuple(cls, new Object[realSize]);
179+
Object[] values = new Object[realSize];
180+
Arrays.fill(values, PNone.NO_VALUE); // Initialize to C NULL
181+
return factory.createTuple(cls, values);
179182
}
180183
} catch (CannotCastException e) {
181184
throw CompilerDirectives.shouldNotReachHere("attribute 'n_fields' is expected to be a Java int");

0 commit comments

Comments
 (0)