[Python-Dev] dictproxy for other mapping types than dict (original) (raw)
Victor Stinner victor.stinner at gmail.com
Thu Mar 22 13:44:00 CET 2012
- Previous message: [Python-Dev] Python-Dev Digest, Vol 104, Issue 79
- Next message: [Python-Dev] PendingDeprecationWarning
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: [Python-Dev] Python-Dev Digest, Vol 104, Issue 79
- Next message: [Python-Dev] PendingDeprecationWarning
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]