From 93378fb3efa67ec15fe3ed5325f6ed87581f5798 Mon Sep 17 00:00:00 2001 From: Amr Hassan Date: Sun, 26 Oct 2008 23:07:12 +0000 Subject: [PATCH] * toStr() is now less crashy. --- changes.txt | 1 + pylast.py | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/changes.txt b/changes.txt index b42e8c0..c4101ac 100644 --- a/changes.txt +++ b/changes.txt @@ -1,5 +1,6 @@ 0.2.16 * All the getTopTags and getTopTagsWithCounts return an empty sequence if failed instead of None. + * toStr() is now less crashy. 0.2.15 * API Breakage, changed the design of Asynchronizer.async_call. diff --git a/pylast.py b/pylast.py index e921e06..24a8453 100644 --- a/pylast.py +++ b/pylast.py @@ -708,7 +708,7 @@ class Album(BaseObject, Cacheable, Taggable): def toStr(self): """Returns a string representation of the object.""" - return self.getArtist().getName() + u' - ' + self.getTitle() + return self.getArtist().getName().encode('utf-8') + ' - ' + self.getTitle().encode('utf-8') class Track(BaseObject, Cacheable, Taggable): """A Last.fm track.""" @@ -1028,7 +1028,7 @@ class Track(BaseObject, Cacheable, Taggable): def toStr(self): """Returns a string representation of the object.""" - return self.getArtist().getName() + u' - ' + self.getTitle() + return self.getArtist().getName().encode('utf-8') + ' - ' + self.getTitle().encode('utf-8') class Artist(BaseObject, Cacheable, Taggable): """A Last.fm artist.""" @@ -1311,7 +1311,7 @@ class Artist(BaseObject, Cacheable, Taggable): def toStr(self): """Returns a string representation of the object.""" - return self.getName() + return self.getName().encode('utf-8') class Event(BaseObject, Cacheable): """A Last.fm event.""" @@ -1521,17 +1521,17 @@ class Event(BaseObject, Cacheable): artists = self.getArtists() for i in range(0, len(artists)): if i == 0: - sa = artists[i].getName() + sa = artists[i].getName().encode('utf-8') continue elif i< len(artists)-1: sa += ', ' - sa += artists[i].getName() + sa += artists[i].getName().encode('utf-8') continue elif i == len(artists) - 1: sa += ' and ' - sa += artists[i].getName() + sa += artists[i].getName().encode('utf-8') - return "%(title)s: %(artists)s at %(place)s" %{'title': self.getTitle(), 'artists': sa, 'place': self.getVenueName()} + return "%(title)s: %(artists)s at %(place)s" %{'title': self.getTitle().encode('utf-8'), 'artists': sa, 'place': self.getVenueName().encode('utf-8')} class Country(BaseObject): """A country at Last.fm.""" @@ -1619,7 +1619,7 @@ class Country(BaseObject): def toStr(self): """Returns a string representation of the object.""" - return self.getName() + return self.getName().encode('utf-8') class Group(BaseObject): """A Last.fm group.""" @@ -1750,7 +1750,7 @@ class Group(BaseObject): def toStr(self): """Returns a string representation of the object.""" - return self.getName() + return self.getName().encode('utf-8') class Library(BaseObject): """A user's Last.fm library.""" @@ -2227,7 +2227,7 @@ class Tag(BaseObject): def toStr(self): """Returns a string representation of the object.""" - return self.getName() + return self.getName().encode('utf-8') class User(BaseObject, Cacheable): """A Last.fm user.""" @@ -2791,7 +2791,7 @@ class User(BaseObject, Cacheable): def toStr(self): """Returns a string representation of the object.""" - return self.getName() + return self.getName().encode('utf-8') class Search(BaseObject): """An abstract search class. Use one of its derivatives."""