[issue44867] types.MappingProxyType and collections.defaultdict

Raymond Hettinger report at bugs.python.org
Sun Aug 8 16:19:44 EDT 2021


Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:

> `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.

Technically, the underlying mapping is modifying itself.  That is allowed.

Also, there isn't really anything that the mapping proxy can do about it.  All MappingProxy can do it forward calls to methods that are usually non-mutating.

----------
assignee:  -> rhettinger
nosy: +rhettinger
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44867>
_______________________________________


More information about the Python-bugs-list mailing list