summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/subclass_native1.py
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2025-01-20 22:23:48 +1100
committerDamien George <damien@micropython.org>2025-02-11 16:51:50 +1100
commitceb8ba60b4fea0c32e4977d0e45d5c0203b27b34 (patch)
tree9c100e265c53509822ecc08155545701a370db6f /tests/basics/subclass_native1.py
parent62e821ccb82fd8362a8198ad59ccb51b8a5c441e (diff)
downloadmicropython-ceb8ba60b4fea0c32e4977d0e45d5c0203b27b34.tar.gz
micropython-ceb8ba60b4fea0c32e4977d0e45d5c0203b27b34.zip
py/objfun: Implement function.__code__ and function constructor.
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>
Diffstat (limited to 'tests/basics/subclass_native1.py')
-rw-r--r--tests/basics/subclass_native1.py6
1 files changed, 2 insertions, 4 deletions
diff --git a/tests/basics/subclass_native1.py b/tests/basics/subclass_native1.py
index 288a686d1a..74b377eac9 100644
--- a/tests/basics/subclass_native1.py
+++ b/tests/basics/subclass_native1.py
@@ -21,11 +21,9 @@ print(a + [20, 30, 40])
# TODO: Faults
#print(a + a)
-def foo():
- print("hello from foo")
-
+# subclassing a type that doesn't have make_new at the C level (not allowed)
try:
- class myfunc(type(foo)):
+ class myfunc(type([].append)):
pass
except TypeError:
print("TypeError")