Message391027
This isn't a bug because the MappingProxy doesn't promise to do early detection and because it can't really be accomplished cleanly.
Perfect detection of non-mappings isn't possible. Some easy, minimal checks are made for early detection using PyMapping_Check, PyList_Check, and PyTuple_Check. Anything that gets past those checks will just need to be duck-typed downstream when it is used.
We could add a few other specific exclusions but that isn't a general solution and it slows down instantiation. Further it could break code that is intended to work (subclasses of str that mapping methods) or that just happen to work:
>>> from types import MappingProxyType
>>> mp = MappingProxyType('abc')
>>> mp[0]
'a' |
|
Date |
User |
Action |
Args |
2021-04-14 03:09:09 | rhettinger | set | recipients:
+ rhettinger, andymaier |
2021-04-14 03:09:09 | rhettinger | set | messageid: <1618369749.33.0.0570221783503.issue43828@roundup.psfhosted.org> |
2021-04-14 03:09:09 | rhettinger | link | issue43828 messages |
2021-04-14 03:09:09 | rhettinger | create | |
|