diff options
author | Lucas Hoffmann <l-m-h@web.de> | 2017-08-20 11:47:55 +0200 |
---|---|---|
committer | Lucas Hoffmann <l-m-h@web.de> | 2017-08-20 12:09:58 +0200 |
commit | 20dab95640592bd4f539a8a781f0c80c21cc5708 (patch) | |
tree | f7786072840fb188b25c1d913a1d17676dbb4d03 | |
parent | a91ee3f8592f7abcb405dc30ef8e8279dc9a09fd (diff) |
Use a tuple to build a hash value
The old implementation would raise an error when the translated tag
string was a unicode string (might be defined as an abbreviation in the
users config).
The official docs suggest this kind of implementation:
https://docs.python.org/3/reference/datamodel.html#object.__hash__
-rw-r--r-- | alot/widgets/globals.py | 2 | ||||
-rw-r--r-- | tests/widgets/globals_test.py | 1 |
2 files changed, 1 insertions, 2 deletions
diff --git a/alot/widgets/globals.py b/alot/widgets/globals.py index f602add0..6ce29827 100644 --- a/alot/widgets/globals.py +++ b/alot/widgets/globals.py @@ -290,7 +290,7 @@ class TagWidget(urwid.AttrMap): self.translated = representation['translated'] self.hidden = self.translated == '' self.txt = urwid.Text(self.translated, wrap='clip') - self.__hash = hash('{}_{}'.format(self.translated, self.txt)) + self.__hash = hash((self.translated, self.txt)) normal_att = representation['normal'] focus_att = representation['focussed'] self.attmaps = {'normal': normal_att, 'focus': focus_att} diff --git a/tests/widgets/globals_test.py b/tests/widgets/globals_test.py index 91092264..bcbf51e1 100644 --- a/tests/widgets/globals_test.py +++ b/tests/widgets/globals_test.py @@ -40,7 +40,6 @@ class TestTagWidget(unittest.TestCase): sorted(globals_.TagWidget(x) for x in expected)] self.assertListEqual(actual, expected) - @unittest.expectedFailure def test_hash_for_unicode_representation(self): with mock.patch( 'alot.widgets.globals.settings.get_tagstring_representation', |