Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix UnicodeEncodeError on latin-1 #844

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

JervisTetch
Copy link

@@ -36,7 +36,7 @@ def save():
hf.write('#EXTM3U\n\n')
if 'history' in g.userhist:
for song in g.userhist['history'].songs:
hf.write('#EXTINF:%d,%s\n' % (song.length, song.title))
hf.write('#EXTINF:%d,%s\n' % (song.length, song.title.encode('utf-8')))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look right to me.

Look at the behavior of this code, for instance: "encoded: %s" % ("test".encode("utf8"),). This results in the string "encoded: b'test'". So it produces a str (not bytes) containing b' and '.

I'm not sure the best solution here. If we want to save the file as UTF-8, then we can pass an encoding= argument to open.

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

Successfully merging this pull request may close these issues.

None yet

3 participants