Message390935
MappingProxyType objects can currently be initialized from a string object. Given is purpose, I think this is a bug and should result in TypeError being raised.
Example code (on CPython 3.9.1):
>>> from types import MappingProxyType
>>> mp = MappingProxyType('abc')
>>> list(mp)
['a', 'b', 'c']
>>> mp.items()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'str' object has no attribute 'items'
Other invalid input types are properly checked:
>>> mp = MappingProxyType(42)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: mappingproxy() argument must be a mapping, not int
>>> mp = MappingProxyType(['a'])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: mappingproxy() argument must be a mapping, not list
>>> mp = MappingProxyType(('a',))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: mappingproxy() argument must be a mapping, not tuple |
|
Date |
User |
Action |
Args |
2021-04-13 08:11:21 | andymaier | set | recipients:
+ andymaier |
2021-04-13 08:11:21 | andymaier | set | messageid: <1618301481.88.0.305881121954.issue43828@roundup.psfhosted.org> |
2021-04-13 08:11:21 | andymaier | link | issue43828 messages |
2021-04-13 08:11:21 | andymaier | create | |
|