xgate1 / pylast

Automatically exported from code.google.com/p/pylast
Apache License 2.0
0 stars 0 forks source link

Several object types are unhashable in Python 3 #81

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Please type example code that produces the issue:
user = network.get_user('Username')
track = user.get_now_playing()
tracks = set()
tracks.add(track)

What is the expected output? What do you see instead?
The track should be added to the set. Instead, a TypeError is raised, declaring 
that the object is unhashable.

What versions of Pylast and Python are you using?
r61c1a6a2c853 and 3.2/3.3.

Please provide any additional information below.
In py3k, if __eq__ is defined, __hash__ must be defined or the object will be 
unhashable.
http://stackoverflow.com/questions/1608842/types-that-define-eq-are-unhashable-i
n-python-3-x
I think that adding __hash__ = _BaseObject.__hash__ in definitions of objects 
that inherit from _BaseObject will solve this issue, but I'm not 100% sure 
that's the best solution.

Original issue reported on code.google.com by bahamutzero8825 on 5 Aug 2012 at 1:56

GoogleCodeExporter commented 8 years ago
`Album`s, `Artist`s, `Event`s, `Tag`s and `Track`s are hashable on Python 3.3 
in my fork: https://github.com/hugovk/pylast/issues/82
Let me know if you need any others doing.

Original comment by hugovk@gmail.com on 2 Mar 2014 at 4:44