diff --git a/src/awkward/_v2/contents/content.py b/src/awkward/_v2/contents/content.py index 0d0978d118..15097d32e7 100644 --- a/src/awkward/_v2/contents/content.py +++ b/src/awkward/_v2/contents/content.py @@ -477,7 +477,7 @@ def __getitem__(self, where): and where._parameters is not None and (where._parameters.get("__array__") in ("string", "bytestring")) ): - return self._getitem_fields(ak.to_list(where)) + return self._getitem_fields(ak._v2.operations.convert.to_list(where)) elif isinstance(where, ak._v2.contents.emptyarray.EmptyArray): return where.toNumpyArray(np.int64) diff --git a/src/awkward/operations/convert.py b/src/awkward/operations/convert.py index eb587b4a11..4bb64ce40c 100644 --- a/src/awkward/operations/convert.py +++ b/src/awkward/operations/convert.py @@ -1008,12 +1008,10 @@ def to_list(array): ak._v2.highlevel.Record, ak._v2.contents.Content, ak._v2.record.Record, + ak._v2.highlevel.ArrayBuilder, ), ): - return array.to_list() - - elif isinstance(array, ak._v2.highlevel.ArrayBuilder): - return array.snapshot().to_list() + raise TypeError("use ak._v2.operations.convert.to_list for v2 arrays (for now)") elif isinstance(array, dict): return dict((n, to_list(x)) for n, x in array.items()) diff --git a/tests/v2/test_0111-jagged-and-masked-getitem.py b/tests/v2/test_0111-jagged-and-masked-getitem.py index 457aa46e0f..2e515c92c7 100644 --- a/tests/v2/test_0111-jagged-and-masked-getitem.py +++ b/tests/v2/test_0111-jagged-and-masked-getitem.py @@ -180,7 +180,9 @@ def test_array_slice_1(): check_valid=True, ).layout array = v1_to_v2(array) - assert to_list(array[ak.from_iter(["y", "x"], highlevel=False)]) == [ + assert to_list( + array[ak._v2.operations.convert.from_iter(["y", "x"], highlevel=False)] + ) == [ {"y": 1.1, "x": 1}, {"y": 2.2, "x": 2}, {"y": 3.3, "x": 3},