[New-bugs-announce] [issue43828] MappingProxyType accepts string
Andy Maier
report at bugs.python.org
Tue Apr 13 04:11:21 EDT 2021
New submission from Andy Maier <andreas.r.maier at gmx.de>:
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
----------
components: Library (Lib)
messages: 390935
nosy: andymaier
priority: normal
severity: normal
status: open
title: MappingProxyType accepts string
versions: Python 3.9
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43828>
_______________________________________
More information about the New-bugs-announce
mailing list