Re: Unicode decoding error

2017-04-13 Thread Mike Dewhirst
Thanks Christophe Mike On 13/04/2017 2:31 AM, Christophe Pettus wrote: On Apr 12, 2017, at 02:26, Antonis Christofides wrote: Does this mean I should globally replace "str(" with "|six.text_type(" in a 2/3 codebase?| I don't think so; afaiu this must be done for the return value of __str__

Re: Unicode decoding error

2017-04-12 Thread Christophe Pettus
> On Apr 12, 2017, at 02:26, Antonis Christofides > wrote: > >> Does this mean I should globally replace "str(" with "|six.text_type(" in a >> 2/3 codebase?| > I don't think so; afaiu this must be done for the return value of __str__(), > not > everywhere. The rules as I understand them are:

Re: Unicode decoding error

2017-04-12 Thread Antonis Christofides
> Does this mean I should globally replace "str(" with "|six.text_type(" in a > 2/3 codebase?| I don't think so; afaiu this must be done for the return value of __str__(), not everywhere. Antonis Christofides http://djangodeployment.com On 2017-04-12 02:33, Mike Dewhirst wrote: > On 12/04/2017 2:

Re: Unicode decoding error

2017-04-11 Thread Mike Dewhirst
On 12/04/2017 2:52 AM, Tim Graham wrote: As ​documented you must return /text/ and not /bytes/ from |__str__()| when using |@python_2_unicode_compatible|. That means |six.text_type(self.a)| ra

Re: Unicode decoding error

2017-04-11 Thread Christophe Pettus
Thanks, and thanks for accepting my documentation change suggestion! https://github.com/django/django/pull/8349 > On Apr 11, 2017, at 09:52, Tim Graham wrote: > > As ​documented you must return text and not bytes from __str__() when using > @python_2_unicode_compatible. That means six.

Re: Unicode decoding error

2017-04-11 Thread Tim Graham
As ​documented you must return *text* and not *bytes* from __str__() when using @python_2_unicode_compatible. That means six.text_type(self.a) rather than str(self.a) (which returns bytes on P

Unicode decoding error

2017-04-11 Thread Christophe Pettus
I've run into the issue described in the code below, where (as far as I can tell) a natural use of __str__ in Python 2.7 results in a Unicode error. I'm not quite sure how to write this code to work properly on both Python 2 and Python 3; what am I missing? (Note this issue happens on Python 2