Skip to content

Commit deccbf0

Browse files
committed
Update by review comments
1 parent b3617c8 commit deccbf0

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

Lib/test/test_array.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1681,24 +1681,25 @@ def test_gh_128961(self):
16811681
it.__setstate__(0)
16821682
self.assertRaises(StopIteration, next, it)
16831683

1684+
# Tests for NULL pointer dereference in array.__setitem__
1685+
# when the index conversion mutates the array.
1686+
# See: gh-142555.
16841687
@subTests(
16851688
("dtype", "items"),
16861689
[
1687-
("b", [0] * 64),
1688-
("B", [1, 2, 3]),
1689-
("h", [1, 2, 3]),
1690-
("H", [1, 2, 3]),
1691-
("i", [1, 2, 3]),
1692-
("l", [1, 2, 3]),
1693-
("q", [1, 2, 3]),
1694-
("I", [1, 2, 3]),
1695-
("L", [1, 2, 3]),
1696-
("Q", [1, 2, 3]),
1690+
("b", list(range(64))),
1691+
("B", list(range(64))),
1692+
("h", list(range(64))),
1693+
("H", list(range(64))),
1694+
("i", list(range(64))),
1695+
("l", list(range(64))),
1696+
("q", list(range(64))),
1697+
("I", list(range(64))),
1698+
("L", list(range(64))),
1699+
("Q", list(range(64))),
16971700
],
16981701
)
16991702
def test_setitem_use_after_clear_with_int_data(self, dtype, items):
1700-
# gh-142555: Test for null pointer dereference in array.__setitem__
1701-
# via re-entrant __index__ that clears the array.
17021703
victim = array.array(dtype, items)
17031704

17041705
class Index:
@@ -1710,8 +1711,6 @@ def __index__(self):
17101711
self.assertEqual(len(victim), 0)
17111712

17121713
def test_setitem_use_after_shrink_with_int_data(self):
1713-
# gh-142555: Test for null pointer dereference in array.__setitem__
1714-
# via re-entrant __index__ that shrinks the array.
17151714
victim = array.array('b', [1, 2, 3])
17161715

17171716
class Index:
@@ -1724,8 +1723,6 @@ def __index__(self):
17241723

17251724
@subTests("dtype", ["f", "d"])
17261725
def test_setitem_use_after_clear_with_float_data(self, dtype):
1727-
# gh-142555: Test for null pointer dereference in array.__setitem__
1728-
# via re-entrant __float__ that clears the array.
17291726
victim = array.array(dtype, [1.0, 2.0, 3.0])
17301727

17311728
class Float:

0 commit comments

Comments
 (0)