You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "Joris Van den Bossche (Jira)" <ji...@apache.org> on 2021/06/04 11:26:00 UTC

[jira] [Comment Edited] (ARROW-12893) [Python] Slicing array can lead to negative length

    [ https://issues.apache.org/jira/browse/ARROW-12893?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17357267#comment-17357267 ] 

Joris Van den Bossche edited comment on ARROW-12893 at 6/4/21, 11:25 AM:
-------------------------------------------------------------------------

This seems similar to something I recently fixed in https://github.com/apache/arrow/pull/10341 / ARROW-12769, and your snippet runs correctly on master for me?


was (Author: jorisvandenbossche):
This seems similar to https://github.com/apache/arrow/pull/10341 / ARROW-12769, and your snippet runs correctly on master for me?

> [Python] Slicing array can lead to negative length
> --------------------------------------------------
>
>                 Key: ARROW-12893
>                 URL: https://issues.apache.org/jira/browse/ARROW-12893
>             Project: Apache Arrow
>          Issue Type: Bug
>            Reporter: Alessandro Molina
>            Assignee: Alessandro Molina
>            Priority: Major
>
> Slice an arrow array can lead to a negative length, when instead it should never be smaller than 0.
> {code}
> arr = pa.array(range(10))
> assert len(arr[-9:-20]) == 0
> {code}
> {{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}}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)