[Python-Dev] readd u'' literal support in 3.3?
Chris McDonough
chrism at plope.com
Fri Dec 9 07:01:10 CET 2011
On Thu, 2011-12-08 at 21:43 -0800, Guido van Rossum wrote:
> On Thu, Dec 8, 2011 at 9:33 PM, Chris McDonough <chrism at plope.com>
> wrote:
> On Thu, 2011-12-08 at 19:52 -0500, Glyph wrote:
> > Zooming back in to the actual issue this thread is about, I
> think the
> > u""-vs-"" issue is a bit of a red herring, because the
> _real_ problem
> > here is that 2to3 is slow and buggy and so migration efforts
> are
> > starting to work around it, and therefore want to run the
> same code on
> > 3.x and all the way back to 2.5.
>
>
> Even if it weren't slow, I still wouldn't use it to
> automatically
> convert code at install time; a single codebase is easier to
> reason
> about, and easier to support. Users send me tracebacks all
> the time;
> having them match the source is a wonderful thing.
>
> Even though 2to3 was my idea, I am gradually beginning to appreciate
> this approach. I skimmed the docs for "six" and liked it.
>
> But I think the specific proposal of adding u"..." literals back to
> 3.3 is not going to do much good. If we had had the foresight way back
> when, we could have added them back to 3.1 and we would have been
> okay. But having them in 3.3 but not in 3.2 is just adding insult to
> injury.
AFAICT, at the current pace of porting, lots of authors of existing,
popular Python 2 libraries won't be releasing a ported/straddled version
any time soon; almost certainly many won't even begin work on a port
until after 3.3 is final. As a result, on the supplier side, there will
be plenty of code that will eventually work only as a straddle across
2.6, 2.7, and 3.3.
On the consumer side, folks who want to run 2.6/2.7/3.3-only codebases
will have the wherewithal to compile their own Python 3 (or use a PPA or
equivalent) until the distros catch up.
So I'm not sure why 3.2 not having support for u'' should be a real
blocker for the change.
> I recommend writing b"...".decode('utf-8'); maybe six's u() does the
> same?
It does this:
def u(s):
return unicode(s, "unicode_escape")
That's two Python function calls, of course, which is obviously icky if
you use a lot of literals at a nonmodule scope.
- C
More information about the Python-Dev
mailing list