micropython/tests/micropython
Jim Mussared a64f2fdca0 py/dynruntime.h: Implement MP_OBJ_NEW_QSTR.
Because mpy_ld.py doesn't know the target object representation, it emits
instances of `MP_OBJ_NEW_QSTR(MP_QSTR_Foo)` as const string objects, rather
than qstrs. However this doesn't work for map keys (e.g. for a locals dict)
because the map has all_keys_are_qstrs flag is set (and also auto-complete
requires the map keys to be qstrs).

Instead, emit them as regular qstrs, and make a functioning MP_OBJ_NEW_QSTR
function available (via `native_to_obj`, also used for e.g. making
integers).

Remove the code from mpy_ld.py to emit qstrs as constant strings, but leave
behind the scaffold to emit constant objects in case we want to do use this
in the future.

Strictly this should be a .mpy sub-version bump, even though the function
table isn't changing, it does lead to a change in behavior for a new .mpy
running against old MicroPython. `mp_native_to_obj` will incorrectly return
the qstr value directly as an `mp_obj_t`, leading to unexpected results.
But given that it's broken at the moment, it seems unlikely that anyone is
relying on this, so it's not work the other downsides of a sub-version bump
(i.e. breaking pure-Python modules that use @native). The opposite case of
running an old .mpy on new MicroPython is unchanged, and remains broken in
exactly the same way.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-09-01 16:14:22 +10:00
..
builtin_execfile.py tests: Replace umodule with module everywhere. 2023-06-08 17:54:24 +10:00
builtin_execfile.py.exp tests/micropython: Add test for builtin execfile() function. 2022-06-29 12:48:42 +10:00
const.py tests/micropython/const.py: Add comment about required config for test. 2021-11-17 14:28:20 +11:00
const.py.exp
const2.py top: Update Python formatting to black "2023 stable style". 2023-02-02 12:51:03 +11:00
const2.py.exp
const_alltypes.py py/parse: Allow all constant objects to be used in "X = const(o)". 2022-05-18 16:18:35 +10:00
const_alltypes.py.exp py/parse: Allow all constant objects to be used in "X = const(o)". 2022-05-18 16:18:35 +10:00
const_error.py py/parse: Support constant folding of power operator for integers. 2020-05-03 16:23:19 +10:00
const_error.py.exp py/parse: Remove unnecessary check in const folding for ** operator. 2020-04-09 16:02:39 +10:00
const_intbig.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
const_intbig.py.exp
decorator.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
decorator.py.exp
decorator_error.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
decorator_error.py.exp
emg_exc.py tests: Replace umodule with module everywhere. 2023-06-08 17:54:24 +10:00
emg_exc.py.exp tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
extreme_exc.py tests/micropython: Fully unlink nested list in extreme exc test. 2022-05-18 09:16:33 +10:00
extreme_exc.py.exp
heap_lock.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
heap_lock.py.exp py/modmicropython: Add heap_locked function to test state of heap. 2020-03-11 16:54:16 +11:00
heap_locked.py py/modmicropython: Add heap_locked function to test state of heap. 2020-03-11 16:54:16 +11:00
heap_locked.py.exp py/modmicropython: Add heap_locked function to test state of heap. 2020-03-11 16:54:16 +11:00
heapalloc.py tests/micropython: Add tests that const tuples don't use the heap. 2022-04-15 00:17:02 +10:00
heapalloc.py.exp tests/micropython: Add tests that const tuples don't use the heap. 2022-04-15 00:17:02 +10:00
heapalloc_bytesio.py tests: Replace umodule with module everywhere. 2023-06-08 17:54:24 +10:00
heapalloc_bytesio.py.exp
heapalloc_bytesio2.py tests: Replace umodule with module everywhere. 2023-06-08 17:54:24 +10:00
heapalloc_bytesio2.py.exp
heapalloc_exc_compressed.py tests/micropython: Switch from set.pop to raise-0 to test exc strings. 2022-03-07 16:48:35 +11:00
heapalloc_exc_compressed.py.exp tests/micropython: Switch from set.pop to raise-0 to test exc strings. 2022-03-07 16:48:35 +11:00
heapalloc_exc_compressed_emg_exc.py tests/micropython: Switch from set.pop to raise-0 to test exc strings. 2022-03-07 16:48:35 +11:00
heapalloc_exc_compressed_emg_exc.py.exp tests/micropython: Switch from set.pop to raise-0 to test exc strings. 2022-03-07 16:48:35 +11:00
heapalloc_exc_raise.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
heapalloc_exc_raise.py.exp
heapalloc_fail_bytearray.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
heapalloc_fail_bytearray.py.exp tests/micropython: Add some tests for failed heap allocation. 2019-04-18 14:34:12 +10:00
heapalloc_fail_dict.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
heapalloc_fail_dict.py.exp tests/micropython: Add some tests for failed heap allocation. 2019-04-18 14:34:12 +10:00
heapalloc_fail_list.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
heapalloc_fail_list.py.exp tests/micropython: Add some tests for failed heap allocation. 2019-04-18 14:34:12 +10:00
heapalloc_fail_memoryview.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
heapalloc_fail_memoryview.py.exp tests/micropython: Add some tests for failed heap allocation. 2019-04-18 14:34:12 +10:00
heapalloc_fail_set.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
heapalloc_fail_set.py.exp tests/micropython: Add some tests for failed heap allocation. 2019-04-18 14:34:12 +10:00
heapalloc_fail_tuple.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
heapalloc_fail_tuple.py.exp tests/micropython: Add some tests for failed heap allocation. 2019-04-18 14:34:12 +10:00
heapalloc_inst_call.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
heapalloc_inst_call.py.exp
heapalloc_int_from_bytes.py
heapalloc_int_from_bytes.py.exp
heapalloc_iter.py tests: Replace umodule with module everywhere. 2023-06-08 17:54:24 +10:00
heapalloc_str.py
heapalloc_str.py.exp
heapalloc_super.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
heapalloc_super.py.exp
heapalloc_traceback.py tests: Replace umodule with module everywhere. 2023-06-08 17:54:24 +10:00
heapalloc_traceback.py.exp tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
heapalloc_yield_from.py top: Update Python formatting to black "2023 stable style". 2023-02-02 12:51:03 +11:00
heapalloc_yield_from.py.exp tests/micropython: Add test for yield-from while heap is locked. 2019-12-27 12:34:22 +11:00
import_mpy_invalid.py tests: Replace umodule with module everywhere. 2023-06-08 17:54:24 +10:00
import_mpy_invalid.py.exp py: Rework bytecode and .mpy file format to be mostly static data. 2022-02-24 18:08:43 +11:00
import_mpy_native.py tests: Replace umodule with module everywhere. 2023-06-08 17:54:24 +10:00
import_mpy_native.py.exp tests/micropython: Make import_mpy_native test run on all architectures. 2022-05-26 12:54:43 +10:00
import_mpy_native_gc.py py/dynruntime.h: Implement MP_OBJ_NEW_QSTR. 2023-09-01 16:14:22 +10:00
import_mpy_native_gc.py.exp py/persistentcode: Maintain root ptr list of imported native .mpy code. 2020-08-02 22:34:09 +10:00
kbd_intr.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
kbd_intr.py.exp
meminfo.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
meminfo.py.exp
memstats.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
memstats.py.exp
native_closure.py top: Update Python formatting to black "2023 stable style". 2023-02-02 12:51:03 +11:00
native_closure.py.exp
native_const.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
native_const.py.exp tests/micropython: Test loading const objs in native and viper funcs. 2018-09-27 23:39:08 +10:00
native_const_intbig.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
native_const_intbig.py.exp
native_for.py tests: Move native for test from pybnative to micropython. 2021-01-29 23:57:10 +11:00
native_for.py.exp tests: Move native for test from pybnative to micropython. 2021-01-29 23:57:10 +11:00
native_fun_attrs.py py/objfun: Support function attributes on native functions. 2022-06-25 00:22:15 +10:00
native_fun_attrs.py.exp py/objfun: Support function attributes on native functions. 2022-06-25 00:22:15 +10:00
native_gen.py top: Update Python formatting to black "2023 stable style". 2023-02-02 12:51:03 +11:00
native_gen.py.exp tests/micropython: Add more test cases for native generators. 2022-05-18 15:23:11 +10:00
native_misc.py top: Update Python formatting to black "2023 stable style". 2023-02-02 12:51:03 +11:00
native_misc.py.exp py/emitnative: Ensure stack settling is safe mid-branch. 2021-07-19 23:18:59 +10:00
native_try.py top: Update Python formatting to black "2023 stable style". 2023-02-02 12:51:03 +11:00
native_try.py.exp
native_try_deep.py top: Update Python formatting to black "2023 stable style". 2023-02-02 12:51:03 +11:00
native_try_deep.py.exp
native_while.py tests: Move native while test from pybnative to micropython. 2022-05-26 12:54:43 +10:00
native_while.py.exp tests: Move native while test from pybnative to micropython. 2022-05-26 12:54:43 +10:00
native_with.py top: Update Python formatting to black "2023 stable style". 2023-02-02 12:51:03 +11:00
native_with.py.exp py: Shorten error messages by using contractions and some rewording. 2018-09-20 14:33:10 +10:00
opt_level.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
opt_level.py.exp tests: Split out test for optimisation level and line-no printing. 2019-08-28 12:47:58 +10:00
opt_level_lineno.py tests: Replace umodule with module everywhere. 2023-06-08 17:54:24 +10:00
opt_level_lineno.py.exp tests: Split out test for optimisation level and line-no printing. 2019-08-28 12:47:58 +10:00
schedule.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
schedule.py.exp
stack_use.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
stack_use.py.exp
viper_addr.py py/objarray: Detect bytearray(str) without an encoding. 2022-11-08 23:09:22 +11:00
viper_addr.py.exp py: Allow to pass in read-only buffers to viper and inline-asm funcs. 2019-08-06 15:58:23 +10:00
viper_args.py top: Update Python formatting to black "2023 stable style". 2023-02-02 12:51:03 +11:00
viper_args.py.exp
viper_binop_arith.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_binop_arith.py.exp
viper_binop_arith_uint.py py/emitnative: Implement binary operations for viper uint operands. 2020-06-27 00:24:04 +10:00
viper_binop_arith_uint.py.exp py/emitnative: Implement binary operations for viper uint operands. 2020-06-27 00:24:04 +10:00
viper_binop_bitwise_uint.py py/emitnative: Implement binary operations for viper uint operands. 2020-06-27 00:24:04 +10:00
viper_binop_bitwise_uint.py.exp py/emitnative: Implement binary operations for viper uint operands. 2020-06-27 00:24:04 +10:00
viper_binop_comp.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_binop_comp.py.exp
viper_binop_comp_imm.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_binop_comp_imm.py.exp
viper_binop_comp_uint.py py/emitnative: Implement binary operations for viper uint operands. 2020-06-27 00:24:04 +10:00
viper_binop_comp_uint.py.exp py/emitnative: Implement binary operations for viper uint operands. 2020-06-27 00:24:04 +10:00
viper_binop_divmod.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_binop_divmod.py.exp
viper_binop_multi_comp.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_binop_multi_comp.py.exp
viper_cond.py top: Update Python formatting to black "2023 stable style". 2023-02-02 12:51:03 +11:00
viper_cond.py.exp
viper_const.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_const.py.exp tests/micropython: Test loading const objs in native and viper funcs. 2018-09-27 23:39:08 +10:00
viper_const_intbig.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_const_intbig.py.exp tests/micropython: Test loading const objs in native and viper funcs. 2018-09-27 23:39:08 +10:00
viper_error.py py/emitnative: Implement binary operations for viper uint operands. 2020-06-27 00:24:04 +10:00
viper_error.py.exp py/emitnative: Implement binary operations for viper uint operands. 2020-06-27 00:24:04 +10:00
viper_globals.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_globals.py.exp
viper_import.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_import.py.exp
viper_misc.py tests/micropython: Split viper_misc test into two files. 2023-02-09 16:12:25 +11:00
viper_misc.py.exp tests/micropython: Split viper_misc test into two files. 2023-02-09 16:12:25 +11:00
viper_misc2.py top: Update Python formatting to black "2023 stable style". 2023-02-02 12:51:03 +11:00
viper_misc2.py.exp py/emitnative: Fix x86-64 emitter to generate correct 8/16-bit stores. 2021-05-20 23:43:25 +10:00
viper_misc3.py tests/micropython: Split viper_misc test into two files. 2023-02-09 16:12:25 +11:00
viper_misc3.py.exp tests/micropython: Split viper_misc test into two files. 2023-02-09 16:12:25 +11:00
viper_misc_intbig.py tests: Replace umodule with module everywhere. 2023-06-08 17:54:24 +10:00
viper_misc_intbig.py.exp
viper_ptr8_load.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_ptr8_load.py.exp
viper_ptr8_store.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_ptr8_store.py.exp
viper_ptr16_load.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_ptr16_load.py.exp
viper_ptr16_store.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_ptr16_store.py.exp
viper_ptr32_load.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_ptr32_load.py.exp
viper_ptr32_store.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_ptr32_store.py.exp
viper_storeattr.py py/emitnative: Fix STORE_ATTR viper code-gen when value is not a pyobj. 2022-07-12 17:18:27 +10:00
viper_storeattr.py.exp py/emitnative: Fix STORE_ATTR viper code-gen when value is not a pyobj. 2022-07-12 17:18:27 +10:00
viper_subscr.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_subscr.py.exp
viper_subscr_multi.py py/emitnative: Ensure load_subscr does not clobber existing REG_ARG_2. 2022-11-11 12:25:32 +11:00
viper_subscr_multi.py.exp py/emitnative: Ensure load_subscr does not clobber existing REG_ARG_2. 2022-11-11 12:25:32 +11:00
viper_try.py top: Update Python formatting to black "2023 stable style". 2023-02-02 12:51:03 +11:00
viper_try.py.exp
viper_types.py top: Update Python formatting to black "2023 stable style". 2023-02-02 12:51:03 +11:00
viper_types.py.exp py/native: Improve support for bool type in viper functions. 2019-05-03 23:18:30 +10:00
viper_with.py top: Update Python formatting to black "2023 stable style". 2023-02-02 12:51:03 +11:00
viper_with.py.exp py: Shorten error messages by using contractions and some rewording. 2018-09-20 14:33:10 +10:00