Skip to content

Commit

Permalink
Gtk UI: Fix UnicodeDecodeError after downloads are finished (bug 1834)
Browse files Browse the repository at this point in the history
When all downloads/syncs are finished, gPodder displays a summary of
downloaded episodes, having cut the titles if they are too long.
However, Russian descriptions are regular, non-unicode python strings,
and gPodder may cut only a part of a multi-byte UTF-8 sequence. It
causes an exception like this:
UnicodeDecodeError: 'utf8' codec can't decode byte 0xbe in position 51:
invalid start byte

This patch fixes that by converting the title to a unicode string if
it's not unicode.

This bug is similar to bug 1825, commit
e1ce9b0.
  • Loading branch information
pluton8 committed Aug 3, 2013
1 parent 22efa71 commit 0274a92
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/gpodder/gtkui/main.py
Expand Up @@ -1428,6 +1428,9 @@ def format_episode_list(self, episode_list, max_episodes=10):

result = []
for title in episode_list[:min(len(episode_list), max_episodes)]:
# Bug 1834: make sure title is a unicode string,
# so it may be cut correctly on UTF-8 char boundaries
title = util.convert_bytes(title)
if len(title) > MAX_TITLE_LENGTH:
middle = (MAX_TITLE_LENGTH/2)-2
title = '%s...%s' % (title[0:middle], title[-middle:])
Expand Down

0 comments on commit 0274a92

Please sign in to comment.