New submission from Guo Ci Teo <zgu...@gmail.com>:

`types.MappingProxyType` is documented as 'Read-only proxy of a mapping'.
But if used with a `collections.defaultdict` mapping, it can modify the 
underlying mapping.
```
import collections, types
dd = collections.defaultdict(set)
mpt = types.MappingProxyType(dd)
mpt['__getitem__'] # key inserted
mpt.get('get') # key not inserted
print(dd.items()) # dict_items([('__getitem__', set())])
```

----------
components: Library (Lib)
messages: 399234
nosy: guoci
priority: normal
severity: normal
status: open
title: types.MappingProxyType and collections.defaultdict
type: behavior
versions: Python 3.10, Python 3.11, Python 3.6, Python 3.7, Python 3.8, Python 
3.9

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue44867>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to