summaryrefslogtreecommitdiff
path: root/tests/micropython/native_fun_attrs.py
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2022-06-25 00:05:39 +1000
committerDamien George <damien@micropython.org>2022-06-25 00:22:15 +1000
commite22b7fb4afbf62a9ca3162539c2d0236aefd8945 (patch)
tree8bbf856f1dd860fb151bc5c0f331b08b7fcbd169 /tests/micropython/native_fun_attrs.py
parent268ec1e3eb818c92f2ad0015902afef4c4c59ba5 (diff)
py/objfun: Support function attributes on native functions.
Native functions can just reuse the bytecode function attribute code. Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'tests/micropython/native_fun_attrs.py')
-rw-r--r--tests/micropython/native_fun_attrs.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/micropython/native_fun_attrs.py b/tests/micropython/native_fun_attrs.py
new file mode 100644
index 000000000..e61c86975
--- /dev/null
+++ b/tests/micropython/native_fun_attrs.py
@@ -0,0 +1,25 @@
+# test native function attributes
+
+
+def f():
+ pass
+
+
+if not hasattr(f, "__name__"):
+ print("SKIP")
+ raise SystemExit
+
+
+@micropython.native
+def native_f():
+ pass
+
+
+print(type(native_f.__name__))
+print(type(native_f.__globals__))
+print(native_f.__globals__ is globals())
+
+try:
+ native_f.__name__ = None
+except AttributeError:
+ print("AttributeError")