From: Joar Wandborg Date: Fri, 3 Aug 2012 14:02:18 +0000 (+0200) Subject: Fixed a UnicodeError in the sql.models.MediaEntry X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=79f28e0b938199b13515edbb8e4a3dd12a6ab6a1;p=mediagoblin.git Fixed a UnicodeError in the sql.models.MediaEntry The __repr__() call would crash the process when it tried to convert an unicode title to ASCII for terminal/logfile output. --- diff --git a/mediagoblin/db/sql/models.py b/mediagoblin/db/sql/models.py index 6ce4e06f..7c8c0f99 100644 --- a/mediagoblin/db/sql/models.py +++ b/mediagoblin/db/sql/models.py @@ -212,10 +212,12 @@ class MediaEntry(Base, MediaEntryMixin): return sys.modules[models_module].DATA_MODEL def __repr__(self): + safe_title = self.title.encode('ascii', 'replace') + return '<{classname} {id}: {title}>'.format( classname=self.__class__.__name__, id=self.id, - title=self.title) + title=safe_title) class FileKeynames(Base):