[Python-Dev] dictproxy for other mapping types than dict

Victor Stinner victor.stinner at gmail.com
Thu Mar 22 13:44:00 CET 2012


Hi,

I created the following issue to expose the dictproxy as a builtin type.
http://bugs.python.org/issue14386

I would be interesting to accept any mapping type, not only dict.
dictproxy implementation supports any mapping, even list or tuple, but
I don't want to support sequences because a missing key would raise an
IndexError instead of a KeyError.

My problem is to check the type in C. issubclass(collections.ChainMap,
collections.abc.Sequence) is False which is the expected result, so I
need to implement this check in C. "The "PyMapping_Check(dict) &&
!PyMapping_Check(dict)" fails on ChainMap: type.__new__(ChainMap)
fills tp_as_sequence->sq_item slot is defined because ChainMap has a
__getitem__ method.

Do you have an idea how to implement such test?

Victor


More information about the Python-Dev mailing list