This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author andymaier
Recipients andymaier
Date 2021-04-13.08:11:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1618301481.88.0.305881121954.issue43828@roundup.psfhosted.org>
In-reply-to
Content
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
History
Date User Action Args
2021-04-13 08:11:21andymaiersetrecipients: + andymaier
2021-04-13 08:11:21andymaiersetmessageid: <1618301481.88.0.305881121954.issue43828@roundup.psfhosted.org>
2021-04-13 08:11:21andymaierlinkissue43828 messages
2021-04-13 08:11:21andymaiercreate