Skip to content
This repository was archived by the owner on Apr 20, 2022. It is now read-only.

Fix slice indices failure. #31

Merged
merged 1 commit into from
May 18, 2021
Merged

Fix slice indices failure. #31

merged 1 commit into from
May 18, 2021

Conversation

kattni
Copy link
Contributor

@kattni kattni commented May 18, 2021

Ran into an issue running the Chase animation in the LED Animation library: AttributeError: 'slice' object has no attribute 'indices'. Fixed it.

Tested on QT Py M0.

@kattni kattni requested a review from a team May 18, 2021 18:33
Copy link

@kmatch98 kmatch98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@kattni kattni merged commit cd1dd3e into adafruit:master May 18, 2021
@dunkmann00
Copy link
Contributor

I think this may introduce some potential bugs when the slice values are negative or if values greater than the sequence length are given. Here is the function that handles this in CircuitPython for reference of what needs to be handled: objslice function

But this actually raises the larger question of why did you get that error in the first place? slice objects should have an indices function.

adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request May 19, 2021
Updating https://github.com/adafruit/Adafruit_CircuitPython_Pypixelbuf to 2.2.5 from 2.2.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_Pypixelbuf#31 from kattni/slice-fix
  > "Increase duplicate code check threshold "
@jepler
Copy link
Contributor

jepler commented Jun 4, 2021

Circuitpython's core code has support for "indices" but it's always been disabled (MICROPY_PY_BUILTINS_SLICE_INDICES). Interesting that the use of it slipped into pypixelbuf without notice. We could always try enablng it, it looks like it wouldn't add much code at all.

@dunkmann00
Copy link
Contributor

@jepler I could be wrong but I think this was only introduced after the recent Micropython version merges. If you look at the CircuitPython 6.3 branch MICROPY_PY_BUILTINS_SLICE_INDICES is not present in objslice.c. And the other flags are turned on, so the indices function works.

I'm not able to verify that by testing at the moment, but I do remember when I worked on this library a while back indices was working.

@jepler
Copy link
Contributor

jepler commented Jun 4, 2021

OK, yeah, I see that. Mind filing an issue at circuitpython so someone can fix it? It does look like it regressed from 6.3 to main.

@dunkmann00
Copy link
Contributor

Sure thing 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants