Crashed with UnicodeDecodeError in set_menu()

Bug #1102644 reported by karl pihlblad
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
mythtv-indicator
Fix Released
High
doug

Bug Description

Mythtv-indicator.py crashed with UnicodeDecodeError in set_menu(): 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128)

Intermittent crashes due to that certain days have non-ascii characters in them... Like mondays... :-)

Traceback:
 Traceback (most recent call last):
   File "/usr/share/mythtv-indicator/mythtv-indicator.py", line 957, in <module>
     MYTHTV_INDICATOR = Mythtvindicator()
   File "/usr/share/mythtv-indicator/mythtv-indicator.py", line 157, in __init__
     self.work()
   File "/usr/share/mythtv-indicator/mythtv-indicator.py", line 165, in work
     self.set_menu()
   File "/usr/share/mythtv-indicator/mythtv-indicator.py", line 327, in set_menu
     tzlocal()).strftime(commwi.DATE_FORMAT1)
 UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128)

stftime seems to barf out an 8-bit string containing utf-8 instead of a python unicode (16/32) string.

A quick fix would be to add a .decode('utf-8') to strftime something like this:

                verbage = _(u'Next: %s') % \
                    self.next_scheduled['starttime'].replace(
                        tzinfo=tzutc()).astimezone(
                        tzlocal()).strftime(commwi.DATE_FORMAT1).decode('utf-8')

Actually, the encoding should probably be what's defined in locale.getlocale(locale.LC_TIME)[1]

I've cobbled together a a patch that tries to find out what encoding is in use, and fix all strftime calls in this way.

Revision history for this message
karl pihlblad (karl-pihlblad) wrote :
doug (r-d-vaughan)
Changed in mythtv-indicator:
assignee: nobody → doug (r-d-vaughan)
status: New → In Progress
importance: Undecided → High
doug (r-d-vaughan)
Changed in mythtv-indicator:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.