Skip to content

Commit 671a63e

Browse files
Bug fix #454: Implement __hash__() in newstr
1 parent d94fb35 commit 671a63e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/future/types/newstr.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ def __repr__(self):
105105
"""
106106
Without the u prefix
107107
"""
108+
108109
value = super(newstr, self).__repr__()
109110
# assert value[0] == u'u'
110111
return value[1:]
@@ -292,6 +293,13 @@ def __eq__(self, other):
292293
else:
293294
return False
294295

296+
def __hash__(self):
297+
if (isinstance(self, unicode) or
298+
isinstance(self, bytes) and not isnewbytes(self)):
299+
return super(newstr, self).__hash__()
300+
else:
301+
raise NotImplementedError()
302+
295303
def __ne__(self, other):
296304
if (isinstance(other, unicode) or
297305
isinstance(other, bytes) and not isnewbytes(other)):

0 commit comments

Comments
 (0)