LWN.net Logo

Needed: Gentle transition path

Needed: Gentle transition path

Posted Oct 22, 2009 11:04 UTC (Thu) by epa (subscriber, #39769)
In reply to: Needed: Gentle transition path by dwheeler
Parent article: Proposal: Moratorium on Python language changes

Isn't the idea that you port your code to Python 2.6, which will give you warnings when you use Python-3-unsafe constructs? Once it runs cleanly under 2.6 you should be able to switch over to 3 when you want. (I'm not a Python hacker so please correct me if I got the wrong impression.)


(Log in to post comments)

Needed: Gentle transition path

Posted Oct 22, 2009 14:20 UTC (Thu) by foom (subscriber, #14868) [Link]

That's pretty much the idea. But there's a couple problems:
  • Once you're on 2.6, without warnings, you need to run your code through the "2to3" converter.. It's a great idea, but it's not *perfect*. There's still a lot of manual work. Especially because mixed in with all the syntax and other removals/deprecations, the fundamental string model changed.

    As the Python 3 "What's New" document says: "Everything you thought you knew about binary data and Unicode has changed." So, basically every usage of python2 "str" (8bit) strings needs to be checked by a human to see if it was intended to be a raw bytestring, or a textual string.

  • Many projects want to stay compatible with some version of Python < 2.6 for a year or so more, since 2.6 just came out recently, and most users don't have it installed yet. E.g. RHEL 5 comes with python 2.4, and the last Debian release comes with 2.5.
  • Python 2.6 doesn't do it (yet)

    Posted Oct 22, 2009 16:50 UTC (Thu) by dwheeler (guest, #1216) [Link]

    Yes, in theory, you can use Python 2.6 and "import from __future" to get a Python 3.0-like language, and use a Python subset so that 2to3 can catch the rest. But it isn't easy. And that's the advantage of Python: Usually, stuff is easy.

    Copyright © 2012, Eklektix, Inc.
    Comments and public postings are copyrighted by their creators.
    Linux is a registered trademark of Linus Torvalds