micropython/tools
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
..
autobuild cc3200/Makefile: Build firmware.zip. 2023-08-24 15:44:20 +10:00
mpremote tools/mpremote: Make soft-reset count as an action. 2023-08-10 14:11:53 +10:00
.gitattributes
.gitignore
cc1
ci.sh rp2: Rename PICO, PICO_W to RPI_PICO, RPI_PICO_W. 2023-08-23 15:49:37 +10:00
codeformat.py tools/codeformat.py: Use pyproject.toml for black config. 2023-08-10 11:54:36 +10:00
codestats.sh
dfu.py
file2h.py
gen-changelog.sh
gen-cpydiff.py
hci_trace_to_pcap.py extmod/modbluetooth: Make all HCI transports trace in the same format. 2023-04-26 11:37:20 +10:00
insert-usb-ids.py all: Fix strings with backslash by using raw string literals. 2023-05-02 11:55:02 +10:00
makemanifest.py
manifestfile.py tools/manifestfile.py: Fix license capturing. 2023-05-19 21:56:38 +10:00
metrics.py renesas-ra: Change MICROPY_HW_BOARD_NAME definition to product name. 2023-04-27 14:12:53 +10:00
mpy-tool.py tools/mpy-tool.py: Ignore linter failure in Python 2 compatibility code. 2023-08-16 16:16:44 +10:00
mpy_bin2res.py
mpy_cross_all.py
mpy_ld.py py/dynruntime.h: Implement MP_OBJ_NEW_QSTR. 2023-09-01 16:14:22 +10:00
pyboard.py all: Replace all uses of umodule in Python code. 2023-06-08 17:54:24 +10:00
pydfu.py tools/pydfu.py: Use getattr to retrieve getargspec function. 2023-05-24 12:00:32 +10:00
tinytest-codegen.py extmod/modtimeq: Remove timeq module. 2023-06-08 17:54:28 +10:00
uf2conv.py all: Fix strings with backslash by using raw string literals. 2023-05-02 11:55:02 +10:00
uf2families.json
uncrustify.cfg all: Fix spelling mistakes based on codespell check. 2023-04-27 18:03:06 +10:00
verifygitlog.py CODECONVENTIONS: Require that commits be signed-off by the author. 2023-05-08 12:20:56 +10:00