[issue27399] ChainMap.keys() is broken

2016-06-27 Thread R. David Murray

Changes by R. David Murray :


--
nosy: +rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27399] ChainMap.keys() is broken

2016-06-27 Thread Zahari Dim

Changes by Zahari Dim :


--
resolution:  -> not a bug
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27399] ChainMap.keys() is broken

2016-06-27 Thread Zahari Dim

New submission from Zahari Dim:

When trying to see if the keys() of a collections.ChainMap object are empty, it 
tries to compute the hash of the dicts that compose the ChainMap, giving rise 
to an error:

In [1]: from collections import ChainMap

In [2]: m = ChainMap([{'a':1}, {'b':2}])

In [3]: bool(m.keys())
---
TypeError Traceback (most recent call last)
 in ()
> 1 bool(m.keys())

/home/zah/anaconda3/lib/python3.5/_collections_abc.py in __len__(self)
633 
634 def __len__(self):
--> 635 return len(self._mapping)
636 
637 def __repr__(self):

/home/zah/anaconda3/lib/python3.5/collections/__init__.py in __len__(self)
865 
866 def __len__(self):
--> 867 return len(set().union(*self.maps)) # reuses stored hash 
values if possible
868 
869 def __iter__(self):

TypeError: unhashable type: 'dict'

Also, I can't ask if 'a' is in keys:

In [6]: m.keys()
Out[6]: KeysView(ChainMap([{'a': 1}, {'b': 2}]))
In [9]: ks = m.keys()
In [17]: 'a' in ks
Out[17]: False

--
components: Library (Lib)
messages: 269370
nosy: Zahari.Dim
priority: normal
severity: normal
status: open
title: ChainMap.keys() is broken
versions: Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com