>>> import sys
>>> sys.__dict__
{'__name__': 'sys', 'path': ['', '.frozen', '/home/nakamura/.micropython/lib', '/usr/lib/micropython'], 'argv': [], 'version': '3.4.0; MicroPython v1.20.0-62-g4e4bdbd19 on 2023-05-11', 'version_info': (3, 4, 0), 'implementation': (name='micropython', version=(1, 20, 0), _machine='linux [GCC 9.4.0] version', _mpy=2310), 'platform': 'linux', 'byteorder': 'little', 'maxsize': 9223372036854775807, 'exit': <function>, 'stdin': <io.TextIOWrapper 0>, 'stdout': <io.TextIOWrapper 1>, 'stderr': <io.TextIOWrapper 2>, 'modules': {}, 'exc_info': <function>, 'executable': '/home/nakamura/tmp/micropython', 'print_exception': <function>, 'atexit': <function>, '': 46951508960406}
>>> sys.__dict__['version']
'3.4.0; MicroPython v1.20.0-62-g4e4bdbd19 on 2023-05-11'
>>> sys.__dict__['ps1']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: ps1
I found
sys.__dict__gets strange result.The last item
'': 46951508960406does not exist insysmodule in fact.It is because dict_print tries to print MP_MODULE_ATTR_DELEGATION_ENTRY, the last element of the rom map of sys module.
Similar issue to #8816.
And, by the same reason, we cannot get sys.ps1/ps2 by using
__dict__.