mirror of
https://github.com/micropython/micropython.git
synced 2026-01-05 19:50:30 +01:00
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>
This commit is contained in:
committed by
Damien George
parent
d94141e147
commit
15d0615d5c
13
tests/basics/module_dict.py
Normal file
13
tests/basics/module_dict.py
Normal file
@@ -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__"])
|
||||
Reference in New Issue
Block a user