Closed as not planned
Description
Bug report
A ChainMap will allow for mixed types without throwing an error; however, accessing values from the ChainMap via keys fails once it hits a list, if the desired key follows the list. In the example below, c
will throw a TypeError with the following message: "TypeError: list indices must be integers or slices, not str," while d
will return the correct value.
from collections import ChainMap
a = [0,1,2,3]
b = {'animal': 'dog', 'color': 'black'}
c = ChainMap(a,b)
d = ChainMap(b,a)
c['animal'] (throws error)
d['animal'] (outputs 'dog')
Your environment
- CPython versions tested on: 3.10.6 and master repo branch
- Operating system and architecture: Ubuntu 22.04 x86_64