mirror of
https://github.com/micropython/micropython.git
synced 2025-07-21 13:01:10 +02:00
This allows retrieving the code object of a function using `function.__code__`, and then reconstructing a function from a code object using `FunctionType(code_object)`. This feature is controlled by `MICROPY_PY_FUNCTION_ATTRS_CODE` and is enabled at the full-features level. Signed-off-by: Damien George <damien@micropython.org>
20 lines
356 B
Python
20 lines
356 B
Python
# Test MicroPython-specific restrictions of function.__code__ attribute.
|
|
|
|
try:
|
|
(lambda: 0).__code__
|
|
except AttributeError:
|
|
print("SKIP")
|
|
raise SystemExit
|
|
|
|
|
|
def f_with_children():
|
|
def g():
|
|
pass
|
|
|
|
|
|
# Can't access __code__ when function has children.
|
|
try:
|
|
f_with_children.__code__
|
|
except AttributeError:
|
|
print("AttributeError")
|