8000 Taking slice of memoryview in Viper function crashes PyBoard · Issue #6523 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

Taking slice of memoryview in Viper function crashes PyBoard #6523

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
twisteroidambassador opened this issue Oct 7, 2020 · 1 comment
Open
Labels
bug py-core Relates to py/ directory in source

Comments

@twisteroidambassador
Copy link

On a PyBoard v1.1 with firmware 1.13, put the following code into a file:

import micropython


@micropython.viper
def take_memoryview_slice():
    ba = bytearray(10)
    mv = memoryview(ba)
    slice = mv[0:1]

Running take_memoryview_slice() resets the PyBoard.

@dpgeorge dpgeorge added the py-core Relates to py/ directory in source label Oct 7, 2020
@dpgeorge
Copy link
Member
dpgeorge commented Oct 7, 2020

Thanks for the report, I can confirm the issue (on the unix port).

The problem is that the native emitter in viper mode cannot handle slices with literal integer arguments. To work around it you can use:

import micropython
from micropython import const

@micropython.viper
def take_memoryview_slice():
    ba = bytearray(10)
    mv = memoryview(ba)
    slice = mv[const(0):const(1)]

tannewt pushed a commit to tannewt/circuitpython that referenced this issue Jul 1, 2022
tannewt pushed a commit to tannewt/circuitpython that referenced this issue Jul 11, 2022
@jonnor jonnor added the bug label Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug py-core Relates to py/ directory in source
Projects
None yet
Development

No branches or pull requests

3 participants
0