diff options
author | Jim Mussared <jim.mussared@gmail.com> | 2022-09-13 14:16:58 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2022-09-19 23:22:46 +1000 |
commit | 15d0615d5cad430930d160a8ca3e809d7b82da32 (patch) | |
tree | 3c99ed59b840629ee161eddf09f25514abaa801e /tests/basics/module_dict.py | |
parent | d94141e1473aebae0d3c63aeaa8397651ad6fa01 (diff) |
py/objmodule: Add support for __dict__.
This matches class `__dict__`, and is similarly gated on
MICROPY_CPYTHON_COMPAT. Unlike class though, because modules's globals are
actually dict instances, the result is a mutable dictionary.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'tests/basics/module_dict.py')
-rw-r--r-- | tests/basics/module_dict.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/basics/module_dict.py b/tests/basics/module_dict.py new file mode 100644 index 000000000..c847294f0 --- /dev/null +++ b/tests/basics/module_dict.py @@ -0,0 +1,13 @@ +# test __dict__ attribute of a built-in module +# see import/module_dict.py for the equivalent test on user modules + +import sys + +if not hasattr(sys, "__dict__"): + print("SKIP") + raise SystemExit + + +# dict of a built-in module (read-only) +print(type(sys.__dict__)) +print(sys.__dict__["__name__"]) |