Discussion:
[Agilo for Trac] Genshi UnicodeDecode error in backlog
Martin Häcker
2014-03-12 09:57:01 UTC
Permalink
While using Agilo 0.9.12 with a german locale (de_DE.utf8) we noticed
Genshi throwing a UnicodeDecodeError in '
agilo/scrum/backlog/templates/agilo_backlog.htm' on line 65.

The problem seems to be that datetime.strftime() is used, which will return
strings always in the encoding of the current locale, which then in turn
confuses genshi, which seems to expect either ascii or unicode strings, but
nothing else.

Thus a workaround for this problem is probably something along these lines:

# python

Python 2.6.6 (r266:84292, Jan 22 2014, 09:42:36)

[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2

Type "help", "copyright", "credits" or "license" for more information.
import locale
locale.setlocale(locale.LC_ALL, 'de_DE.utf8')
'de_DE.utf8'
import datetime
d = datetime.datetime.now()
d.strftime("%a %B %d")
'Mi M\xc3\xa4rz 12'
print d.strftime("%a %B %d").decode('utf8')
Mi MÀrz 12
import locale
locale.getlocale()
('de_DE', 'UTF8')
locale.getlocale()[1]
'UTF8'
d.strftime("%a %B %d").decode(locale.getlocale()[1])
u'Mi M\xe4rz 12'
Patching line 65 of 'agilo/scrum/backlog/templates/agilo_backlog.htm' with
this

<!-- decode('utf8') is neccessary, as stftime returns
different encodings depending on the locale-->
<span class="sprint-dates"
py:if="backlog.is_sprint_backlog()">${backlog.sprint().start.strftime("%a
%B %d").decode('utf8')} <span id="sprint-dates-arrow"></span>
${backlog.sprint().end.strftime("%a %B %d").decode('utf8')}</span>


Seems to be a workaround for us for this issue.

Regards,
Martin HÀcker
--
--
Follow Agilo on Twitter: http://twitter.com/agilofortrac
Please support us by reviewing and voting on:
http://userstories.com/products/8-agilo-for-scrum
http://ohloh.net/p/agilo-trac
http://freshmeat.net/projects/agiloforscrum

You have received this message because you are subscribed to
the "Agilo for Trac" Google Group. This group is focused on
supporting Agilo for Trac users and is moderated by
Agilo Software GmbH <http://www.agilosoftware.com>.

To post to this group, send email to agilo-/***@public.gmane.org
To unsubscribe from this group, send an email to
agilo+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/agilo

---
You received this message because you are subscribed to the Google Groups "Agilo for Trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email to agilo+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/d/optout.
Stefano Rago
2014-03-25 13:18:39 UTC
Permalink
Hi Martin,

thanks a lot for sharing your solution and for taking the time to detail the reasoning behind it.

In our next release of Agilo for Trac we will include a fix, and your contribution will surely help.

Cheers
While using Agilo 0.9.12 with a german locale (de_DE.utf8) we noticed Genshi throwing a UnicodeDecodeError in 'agilo/scrum/backlog/templates/agilo_backlog.htm' on line 65.
The problem seems to be that datetime.strftime() is used, which will return strings always in the encoding of the current locale, which then in turn confuses genshi, which seems to expect either ascii or unicode strings, but nothing else.
# python
Python 2.6.6 (r266:84292, Jan 22 2014, 09:42:36)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import locale
locale.setlocale(locale.LC_ALL, 'de_DE.utf8')
'de_DE.utf8'
import datetime
d = datetime.datetime.now()
d.strftime("%a %B %d")
'Mi M\xc3\xa4rz 12'
print d.strftime("%a %B %d").decode('utf8')
Mi März 12
import locale
locale.getlocale()
('de_DE', 'UTF8')
locale.getlocale()[1]
'UTF8'
d.strftime("%a %B %d").decode(locale.getlocale()[1])
u'Mi M\xe4rz 12'
Patching line 65 of 'agilo/scrum/backlog/templates/agilo_backlog.htm' with this
<!-- decode('utf8') is neccessary, as stftime returns different encodings depending on the locale-->
<span class="sprint-dates" py:if="backlog.is_sprint_backlog()">${backlog.sprint().start.strftime("%a %B %d").decode('utf8')} <span id="sprint-dates-arrow"></span> ${backlog.sprint().end.strftime("%a %B %d").decode('utf8')}</span>
Seems to be a workaround for us for this issue.
Regards,
Martin Häcker
--
--
Follow Agilo on Twitter: http://twitter.com/agilofortrac
http://userstories.com/products/8-agilo-for-scrum
http://ohloh.net/p/agilo-trac
http://freshmeat.net/projects/agiloforscrum
You have received this message because you are subscribed to
the "Agilo for Trac" Google Group. This group is focused on
supporting Agilo for Trac users and is moderated by
Agilo Software GmbH <http://www.agilosoftware.com>.
To unsubscribe from this group, send an email to
For more options, visit this group at
http://groups.google.com/group/agilo
---
You received this message because you are subscribed to the Google Groups "Agilo for Trac" group.
For more options, visit https://groups.google.com/d/optout.
Stefano Rago
Software Engineer
Agilo Software GmbH
Gruenberger Str. 54
10245 Berlin, Germany

stefano.rago-CKHYNj9aYvRx67MzidHQgQC/***@public.gmane.org
http://www.agilosoftware.com

Follow us on twitter: http://twitter.com/agiloforscrum, http://twitter.com/agilofortrac

Amtsgericht Charlottenburg: HRB 127146
CEO Marion Eickmann, Andrea Tomasini
--
--
Follow Agilo on Twitter: http://twitter.com/agilofortrac
Please support us by reviewing and voting on:
http://userstories.com/products/8-agilo-for-scrum
http://ohloh.net/p/agilo-trac
http://freshmeat.net/projects/agiloforscrum

You have received this message because you are subscribed to
the "Agilo for Trac" Google Group. This group is focused on
supporting Agilo for Trac users and is moderated by
Agilo Software GmbH <http://www.agilosoftware.com>.

To post to this group, send email to agilo-/***@public.gmane.org
To unsubscribe from this group, send an email to
agilo+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/agilo

---
You received this message because you are subscribed to the Google Groups "Agilo for Trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email to agilo+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/d/optout.
Loading...