[issue43838] There is a way to access an underlying mapping in MappingProxyType

Nick Coghlan report at bugs.python.org
Sat Jul 10 06:27:23 EDT 2021


Nick Coghlan <ncoghlan at gmail.com> added the comment:

I stumbled across this independently in bpo-44596, but missed this existing report due to the specific word I was looking for (encapsulation).

In addition to the comparison operand coercion, there's now another access option through the `__ror__` method.

The bug in both cases arises from delegating a method/function implementation to the underlying mapping type in a way that invokes the full operand coercion dance. (PyObject_RichCompare in one case, PyNumber_Or in the other)

Delegating these operations to the underlying mapping does make sense, but it needs to be a lower level delegation that bypasses the operand coercion dance, so the other operand only ever sees the proxy object, not the underlying mapping.

----------
nosy: +ncoghlan

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


More information about the Python-bugs-list mailing list