Uploaded image for project: 'Apache Arrow'
  1. Apache Arrow
  2. ARROW-12893

[Python] Slicing array can lead to negative length

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • None
    • None
    • None

    Description

      Slice an arrow array can lead to a negative length, when instead it should never be smaller than 0.

      arr = pa.array(range(10))
      assert len(arr[-9:-20]) == 0
      

      Array.length() returns -1 which makes the previous snippet crash as Python never accepts length < 0

      In particular if you have Python in debug mode it will explicitly fail the related assertion
      Assertion failed: (len >= 0 || PyErr_Occurred()), function PyObject_Size, file Objects/abstract.c, line 61

      Attachments

        Issue Links

          Activity

            People

              amol- Alessandro Molina
              amol- Alessandro Molina
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: