Skip to content

Commit 010617d

Browse files
committed
initialize returned array with NO_VALUE in PyListNewNode
1 parent e948662 commit 010617d

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PythonCextBuiltins.java

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,26 +1787,21 @@ public Object newList(VirtualFrame frame, long size,
17871787
return raiseNativeNode.raise(frame, getNativeNullNode.execute(), SystemError, BAD_ARG_TO_INTERNAL_FUNC_S, size);
17881788
}
17891789

1790-
@SuppressWarnings("unused")
1791-
@Specialization(guards = "size == 0")
1792-
public Object newEmptyList(int size) {
1793-
return factory().createList(PythonUtils.EMPTY_OBJECT_ARRAY);
1794-
}
1795-
17961790
@SuppressWarnings("unused")
17971791
@Specialization(guards = "size == 0")
17981792
public Object newEmptyList(long size) {
17991793
return factory().createList(PythonUtils.EMPTY_OBJECT_ARRAY);
18001794
}
18011795

18021796
@Specialization(guards = "size > 0")
1803-
public Object newList(int size) {
1804-
return factory().createList(new Object[size]);
1797+
public Object newList(long size) {
1798+
return factory().createList(array(size));
18051799
}
18061800

1807-
@Specialization(guards = "size > 0")
1808-
public Object newList(long size) {
1809-
return factory().createList(new Object[(int) size]);
1801+
private static Object[] array(long size) {
1802+
Object[] a = new Object[(int) size];
1803+
Arrays.fill(a, PNone.NO_VALUE);
1804+
return a;
18101805
}
18111806
}
18121807

@@ -1963,7 +1958,7 @@ Object getSlice(VirtualFrame frame, PList list, long iLow, long iHigh,
19631958
return getNativeNullNode.execute();
19641959
}
19651960
}
1966-
1961+
19671962
@Specialization
19681963
Object getSlice(VirtualFrame frame, PList list, Object iLow, Object iHigh,
19691964
@Cached com.oracle.graal.python.builtins.objects.list.ListBuiltins.GetItemNode getItemNode,
@@ -2025,7 +2020,7 @@ Object getSlice(VirtualFrame frame, PList list, long iLow, long iHigh, Object s,
20252020
return -1;
20262021
}
20272022
}
2028-
2023+
20292024
@Specialization
20302025
Object getSlice(VirtualFrame frame, PList list, Object iLow, Object iHigh, Object s,
20312026
@Cached com.oracle.graal.python.builtins.objects.list.ListBuiltins.SetItemNode setItemNode,

0 commit comments

Comments
 (0)