diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f54bb8e..49a062e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,13 +6,19 @@ Changelog .. include:: release-notifications.rst.inc -0.14.1 (2017-11-28) -------------------- +0.14.1 (not yet released) +------------------------- -- Fix a bug where hashing a :class:`frozenbidict `\’s - inverse (e.g. ``f = frozenbidict(); {f.inv: 'oops'}``) would result in - ``AttributeError: 'frozenbidict' object has no attribute '_hash'``. +- Fix a bug introduced in 0.14.0 where hashing a + :class:`frozenbidict `\’s inverse + (e.g. ``f = frozenbidict(); {f.inv: '...'}``) + would cause an ``AttributeError``. +- Fix a bug introduced in 0.14.0 for Python 2 users where calling + :meth:`bidict.viewitems() ` + would cause a ``TypeError``. + Thanks Richard Sanger for + `reporting `_. 0.14.0 (2017-11-20) diff --git a/bidict/_frozen.py b/bidict/_frozen.py index 4e2dc19..4ba6b90 100644 --- a/bidict/_frozen.py +++ b/bidict/_frozen.py @@ -326,6 +326,6 @@ class frozenbidict(BidirectionalMapping): # noqa: N801 values.__doc__ = "Like dict's ``values``." # Use ItemsView here rather than proxying to fwdm.viewitems() so that - # OrderedBidictBase (whose fwdm's values are nodes, not bare values) + # ordered bidicts (whose fwdm's values are nodes, not bare values) # can use it. - viewitems = ItemsView + viewitems = lambda self: ItemsView(self) diff --git a/tests/test_bidict.txt b/tests/test_bidict.txt index 2d84ae4..7723f3d 100644 --- a/tests/test_bidict.txt +++ b/tests/test_bidict.txt @@ -211,3 +211,13 @@ inserting existing items is a no-op (i.e. it doesn't raise):: True >>> sorted(b.items(), key=lambda x: x[1]) [('one', 1), ('two', 2), ('three', 3)] + +Python 2 dict view APIs are supported:: + + >>> from bidict.compat import PY2 + >>> sorted(b.viewkeys()) == sorted(b.keys()) if PY2 else True + True + >>> sorted(b.viewvalues()) == sorted(b.values()) if PY2 else True + True + >>> sorted(b.viewitems()) == sorted(b.items()) if PY2 else True + True