Files
micropython/extmod
Damien George 93692caefa extmod/modmarshal: Support marshal.dumps of functions with children.
This commit adds support to the `marshal` module to be able to dump
functions that have child functions.  For example:

    import marshal

    def f():
        def child():
            return 1
        return child

    marshal.dumps(f.__code__)

It also covers the case of marshalling functions that use list
comprehensions, because a list comprehension uses a child function.

This is made possible by the newly enhanced
`mp_raw_code_save_fun_to_bytes()` that can now handle nested functions.

Unmarshalling via `marshal.loads()` already supports nested functions
because it uses the standard `mp_raw_code_load_mem()` function which is
used to import mpy files (and hence can handle all possibilities).

Signed-off-by: Damien George <damien@micropython.org>
2026-01-27 01:20:36 +11:00
..
2019-10-29 14:17:29 +11:00
2017-07-18 11:57:39 +10:00