Crash with encoding error for windowed mode #141

Closed
npassaro opened this Issue Feb 24, 2014 · 10 comments

Comments

Projects
None yet
3 participants

Hi,
Running Hamster with python 2.7.5 and python DBus 1.2.0 crashes with error:

Traceback (most recent call last):
  File "/usr/bin/hamster", line 387, in <module>
    hamster_client.overview()
  File "/usr/bin/hamster", line 152, in overview
    self._launch_window("overview")
  File "/usr/bin/hamster", line 143, in _launch_window
    getattr(server, window_name)()
  File "/usr/lib/python2.7/site-packages/dbus/proxies.py", line 70, in __call__
    return self._proxy_method(*args, **keywords)
  File "/usr/lib/python2.7/site-packages/dbus/proxies.py", line 145, in __call__
    **keywords)
  File "/usr/lib/python2.7/site-packages/dbus/connection.py", line 651, in call_blocking
    message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Python.UnicodeDecodeError: Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/dbus/service.py", line 707, in _message_cb
    retval = candidate_method(self, *args, **keywords)
  File "/usr/lib/hamster-time-tracker/hamster-windows-service", line 38, in overview
    def overview(self): dialogs.overview.show(self.app)
  File "/usr/lib/python2.7/site-packages/hamster/lib/configuration.py", line 93, in show
    dialog = self.get_dialog_class()(parent, **kwargs)
  File "/usr/lib/python2.7/site-packages/hamster/overview.py", line 307, in __init__
    self.header_bar.range_pick.set_range(*date_range)
  File "/usr/lib/python2.7/site-packages/hamster/widgets/dates.py", line 86, in set_range
    self.label.set_markup('<b>%s</b>' % stuff.format_range(start_date, end_date).encode("utf-8"))
  File "/usr/lib/python2.7/site-packages/hamster/lib/stuff.py", line 91, in format_range
    title = (u"%(start_B)s %(start_d)s – %(end_B)s %(end_d)s, %(end_Y)s") % dates_dict
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 3: ordinal not in range(128)

Python last update had a bug.

@npassaro npassaro closed this Feb 25, 2014

mduft commented Mar 11, 2014

have the same issue - python 2.7.5 and python 2.7.6. is there a workaround?

Hi,

I have Fedora 20. To my knowledge, this error appeared after two updates of python and each time an update corrected the issue. Right now I have installed python-2.7.5-11.fc20.

@tbaugis, any thoughts on this?

mduft commented Mar 12, 2014

I'm using gentoo linux :)

Contributor

tstriker commented Mar 12, 2014

hmm, the trouble is i can't replicate the bug. so if you can and have basic python skills - you could dig into what's going on there

mduft commented Mar 13, 2014

i tried to improve my python debugging skills from zero to a little :D i discovered that it seems that in stuff.py:147 the resulting retval string is also b'10' for locale_str b'10', so no unicode there. however there is no exception! it never hits line 149.

thus all elements in the dates_dict are ASCII strings, and thus the replacement of dict values in title fails with an encoding error....

i hope i got this right :D

mduft commented Mar 13, 2014

btw. my defaultencoding is ASCII, as you might already have guessed ;)

mduft commented Mar 13, 2014

getpreferredencoding returns b'UTF-8'. it seems that it erronously believes the string is already utf8? the effect of calling passing utf8 twice is a non unicode string result, it seems :| this is what happens in the locale_to_utf8:

unicode("hugo", "UTF-8").encode("utf-8")
'hugo'

mduft commented Mar 13, 2014

on my machine, system wide:
mduft@s01en22 ~ $ locale
LANG=en_US.utf8
LC_CTYPE="en_US.utf8"
LC_NUMERIC=de_DE.utf8
LC_TIME=de_DE.utf8
LC_COLLATE="en_US.utf8"
LC_MONETARY=de_DE.utf8
LC_MESSAGES="en_US.utf8"
LC_PAPER=de_DE.utf8
LC_NAME="en_US.utf8"
LC_ADDRESS="en_US.utf8"
LC_TELEPHONE="en_US.utf8"
LC_MEASUREMENT=de_DE.utf8
LC_IDENTIFICATION="en_US.utf8"
LC_ALL=

mduft commented Mar 14, 2014

i temporarily "fixed" it, by making all the format strings in stuff.py non-unicode (remove u prefix), and removing the .encode(utf-8) in File "/usr/lib64/python2.7/site-packages/hamster/widgets/dates.py", line 86, in set_range (self.label.set_markup('%s' % stuff.format_range(start_date, end_date).encode("utf-8")))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment