New submission from Andy Maier <andreas.r.ma...@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 <rep...@bugs.python.org> <https://bugs.python.org/issue43828> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com