← index #5547Issue #103
Off-topic · high · value 1.653
QUERY · ISSUE

py/compile: compile built-in with 'single' option is not CPython compatible

openby tveopened 2020-01-17updated 2020-01-20
py-core

In CPython:

Python 3.8.0 (default, Oct 23 2019, 18:51:26)
[GCC 9.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> eval(compile("4+5", "<string>", "single"))
9
>>>

In MicroPython (1.12):

MicroPython v1.12-68-g3032ae115-dirty on 2020-01-15; ESP32 module with ESP32
Type "help()" for more information.
>>> 4+5
9
>>> eval(compile("4+5", "<string>", "single"))
>>>
CANDIDATE · ISSUE

Q: Does MICROPY_EMIT_CPYTHON work?

closedby BigCheeZopened 2014-01-07updated 2014-01-07

I've been working on a port to another MCU but have some questions. The MCU is not ARM based and I have not wrote the code to emit native code. My guess was that I could enable MICROPY_EMIT_CPYTHON and use that for now. Is that true?

I noticed that the mp_compile() function only returns mp_const_true when MICROPY_EMIT_CPYTHON is defined. Then I look in the main.c file for the STM port and see that rt_call_function_0(module_fun); is called after mp_compile(). Since only mp_const_true is being returned the function call fails. What am I missing? How do you call the function after compiling with MICROPY_EMIT_CPYTHON enabled? I feel like I'm missing some core concept.

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