[ckan-dev] __repr__ encoding

Sean Hammond sean.hammond at okfn.org
Mon Mar 18 09:52:24 UTC 2013


> We came across a unicode error in with the history pages in jinja[1].
> As you can see in the traceback, the issue occurs in the debug code
> where we at some point in pprint.pformat repr is called on a
> PackageTag with unicode characters in it. The server doesn't like that
> and crashes. The right solution, imho, is to return a UTF-8 encoded
> string from __repr__. However, there are more places in CKAN, where we
> don't return an encoded string. How do you see this? Should we change
> all __repr__ methods in CKAN, is it just a problem in the case of
> PackageTag or am I holding it wrong[2]?

Yep, I think __repr__() is supposed to return a suitably encoded string,
not unicode, so this is a bug in CKAN.




More information about the ckan-dev mailing list