[Python-Dev] PEP 414 - Unicode Literals for Python 3 (original) (raw)

Vinay Sajip vinay_sajip at yahoo.co.uk
Mon Feb 27 20:16:14 CET 2012


Terry Reedy <tjreedy udel.edu> writes:

This is a point, though this would be a one-time conversion by a 2to23 converter that would be part of other needed conversions, some by hand. I presume that most 2.6 code has problems other than u'' when attempting to run under 3.x.

Right. In doing the Django port, the u() stuff took very little time - I wrote a lib2to3 fixer to do it. A lot more time was spent in areas where the bytes/text interfaces had not been thought through carefully, e.g. in the crypto/hashing stuff - this is stuff that an automatic tools couldn't do.

After it was decided in the Django team to drop 2.5 support after Django 1.4 was released, the u('xxx') calls weren't needed any more. Another lib2to3 fixer converted them back to 'xxx' for use with "from future import unicode_literals".

> 2) Won't atually meet the aesthetic goal, as > it's uglier and slower under both Python 2 and Python 3.

Less relevant. The minor ugliness would be in dual-version code, but not Python 3 itself.

And it would be reasonably easy to transition from u('xxx') -> 'xxx' when support for 2.5 is dropped by a particular project, again using automation via a lib2to3 fixer.

I could claim that a solution that also works for 3.1 and 3.2 is a nobrainer. It depends on how one weighs different factors.

Yes. I feel the same way as Martin and Barry have expressed - it's a shame that people are talking up the potential difficulties of porting to a single code-base without the PEP change. Having been in the trenches with the Django port, I don't feel that the Unicode literal part was really a major problem. And I've now done two Django ports - one to a 2.5-compatible codebase with u('xxx'), and one to a 2.6+ compatible codebase with unicode_literals and plain 'xxx'. I'm only keeping the latter one up to date with changes in Django trunk, but both ports, though far from complete from a whole-project point of view, got to the point where they passed the very large test suite.

On balance, though, I don't oppose the PEP. We can wish all we want for people to do the right thing (as we see it), but wishing don't make it so.

Do I sense a certain amount of worry about the pace of the 2.x -> 3.x transition? It feels like we're blinking first ;-)

Regards,

Vinay Sajip



More information about the Python-Dev mailing list