Re: python_2_unicode_compatible pitfalls

2012-12-28 Thread Mikhail Korobov
пятница, 28 декабря 2012 г., 14:37:46 UTC+6 пользователь Aymeric Augustin написал: > > 2012/12/28 Karen Tracey > > >> On Thu, Dec 27, 2012 at 7:15 PM, Aymeric Augustin < >> aymeric@polytechnique.org > wrote: >> >>> 2) under Python 2.x __str__ is implemented as __unicode__ >>>encoded to u

Re: python_2_unicode_compatible pitfalls

2012-12-28 Thread Mikhail Korobov
Hi Aymeric, FYI: I didn't check anything in my message manually, this is a "code review" based on grepping over django source code for common problems. пятница, 28 декабря 2012 г., 6:15:06 UTC+6 пользователь Aymeric Augustin написал: > > Hi Mikhail, > > Thanks for your feedback! Your email tou

Re: python_2_unicode_compatible pitfalls

2012-12-28 Thread Aymeric Augustin
2012/12/28 Karen Tracey > On Thu, Dec 27, 2012 at 7:15 PM, Aymeric Augustin < > aymeric.augus...@polytechnique.org> wrote: > >> 2) under Python 2.x __str__ is implemented as __unicode__ >>encoded to utf8. >> >> >> Yes, this is a legacy behavior that I strongly disagree with. It >> makes __str

Re: python_2_unicode_compatible pitfalls

2012-12-27 Thread Karen Tracey
On Thu, Dec 27, 2012 at 7:15 PM, Aymeric Augustin < aymeric.augus...@polytechnique.org> wrote: > 2) under Python 2.x __str__ is implemented as __unicode__ >encoded to utf8. > > > Yes, this is a legacy behavior that I strongly disagree with. It > makes __str__ / __unicode__ handling for Model s

Re: python_2_unicode_compatible pitfalls

2012-12-27 Thread Aymeric Augustin
Hi Mikhail, Thanks for your feedback! Your email touches many topics; can we try to extract the most important ones and identify what really needs fixing before the 1.5 release? > 1) @python_2_unicode_compatible doesn't handle __repr__. Indeed, this decorator isn't designed to handle __repr__ —

Re: python_2_unicode_compatible pitfalls

2012-12-27 Thread Mikhail Korobov
Oh, my description of (5) is not totally correct: u'%r' % bytestring_value is fine because repr(non_ascii_bytestring) is an escaped 7bit ascii; this mean HttpResponseBase._convert_to_charset is almost fine (bytes would be of incorrect encoding, but this won't raise an exception). The argument ab

python_2_unicode_compatible pitfalls

2012-12-27 Thread Mikhail Korobov
Hi there, First of all, many kudos for the Python 3.x support in upcoming django 1.5, and for the way it is handled (the approach, the docs, etc)! I think there are some pitfalls with @python_2_unicode_compatible decorator as it currently implemented in django (and __str__/__repr__ in general)