Skip to content
This repository was archived by the owner on Nov 13, 2017. It is now read-only.

UnicodeDecodeError at non-ascii album names #5

Open
janLo opened this issue Dec 5, 2010 · 2 comments
Open

UnicodeDecodeError at non-ascii album names #5

janLo opened this issue Dec 5, 2010 · 2 comments

Comments

@janLo
Copy link

janLo commented Dec 5, 2010

The exception is raised in Playlist rendering. The problem-album-entry ist the folowing:
{'album': 'Boh\xc3\xa8me', 'artist': 'Annett Louisan', 'date': '2004', 'file': 'mp3 Jan/Annett Louis ian/Annett Louisan - Boheme/(Annett Louisan - Boh\xc3\xa8me 01) - Das Spiel.mp3', 'genre': 'Easy Listening', 'id': '790', 'pos': '0', 'time': '182', 'title': 'Das Spiel', 'track': '01'}

The Traceback:
File 'theory/theory/controllers/playlist.py', line 48 in index
return render('/playlist.html')
File 'theory/env/lib/python2.6/site-packages/Pylons-1.0-py2.6.egg/pylons/templating.py', line 243 in render_mako
cache_type=cache_type, cache_expire=cache_expire)
File 'theory/env/lib/python2.6/site-packages/Pylons-1.0-py2.6.egg/pylons/templating.py', line 218 in cached_template
return render_func()
File 'theory/env/lib/python2.6/site-packages/Pylons-1.0-py2.6.egg/pylons/templating.py', line 240 in render_template
return literal(template.render_unicode(*_globs))
File 'theory/env/lib/python2.6/site-packages/Mako-0.3.6-py2.6.egg/mako/template.py', line 292 in render_unicode
as_unicode=True)
File 'theory/env/lib/python2.6/site-packages/Mako-0.3.6-py2.6.egg/mako/runtime.py', line 575 in _render
*_kwargs_for_callable(callable, data))
File 'theory/env/lib/python2.6/site-packages/Mako-0.3.6-py2.6.egg/mako/runtime.py', line 607 in _render_context
_exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
File 'theory/env/lib/python2.6/site-packages/Mako-0.3.6-py2.6.egg/mako/runtime.py', line 633 in exec_template
callable
(context, _args, *_kwargs)
File 'theory/data/templates/body.html.py', line 47 in render_body
__M_writer(escape(self.body()))
File 'theory/data/templates/playlist.html.py', line 97 in render_body
__M_writer(escape(t['album'].replace("'","'")))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 3: ordinal not in range(128)

Thank you
Jan

@janLo
Copy link
Author

janLo commented Dec 5, 2010

Look at janLo@71b5ab3 for a quick and dirty fix

@YenTheFirst
Copy link

I wrote a slightly less quick and dirty fix for this:

I opened up an issue on python-mpd here: http://jatreuman.indefero.net/p/python-mpd/issues/4/

mpd's entire protocol is utf-8 encoded, so the helper should recognize this and automatically decode, but python-mpd doesn't. (Actually, I think putting that fix in place removes the need for a lot of encode() and decode()s in the program)

However, this fix also requires a fix: python2.6's urllib.quote doesn't like Unicode strings, so I changed the onclick line in tracks.html to:
onclick="addToPlaylist('${t['file']}')"

this doesn't look like it introduces any errors, though, since it's automatically escaped anyway by the framework (I think)

I could fork and put in a pull request, if you'd like

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants