← index #15615Issue #17046
Related · high · value 0.665
QUERY · ISSUE

Native code decorator should be best-effort

openby darconeousopened 2024-08-08updated 2026-03-24
bugpy-core

Port, board and/or hardware

MacOS X (Apple Silicon)

MicroPython version

MicroPython v1.23.0 on 2024-05-31; darwin [GCC 4.2.1] version

Reproduction

Try running the following code on a macOS device running Apple Silicon using a version of Micropython built for Apple Silicon:

@micropython.native
def test_fun():
    print("Hello, World!")

Expected behaviour

I understand that native code execution is not supported on Apple Silicon, but I would expect to still be able to generally execute code even if marked up with native decorators (in order words, I would expect them to be ignored in that case).

Observed behaviour

When trying to test this code locally on my MacBook Pro M2, all functions with the decorator @micropython.native end up generating the following exception:

>>> %Run -c $EDITOR_CONTENT
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SyntaxError: invalid micropython decorator
>>> 

Additional Information

I understand that the @micropython.viper decorator has different behavior and might not be a good candidate for being ignored, so we may want different behavior there. Perhaps an opt-in for allowing it to be ignored? Something like this:

@micropython.viper(optional=true)
def test_fun():
    print("Hello, World!")

This would force anyone wanting to test code like this to attest that the behavior would be the same.

Code of Conduct

Yes, I agree

CANDIDATE · ISSUE

Enable MICROPY_EMIT_RV32 for ESP32-C6 but compile error "invalid arch" with decorator @micropython.native

closedby bhcuong2008opened 2025-03-30updated 2025-03-31
bug

Port, board and/or hardware

ESP32 C6

MicroPython version

MicroPython 1.24.1

Reproduction

  1. Create a test file test.py inside frozen folder modules/test.py
  2. Write a function with decorator @micropython.native
  3. Build for target ESP32 C6

Expected behaviour

Compile successfully.

Observed behaviour

Compile failed with error "invalid arch"

Additional Information

No, I've provided everything above.

Code of Conduct

Yes, I agree

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied