[Python-Dev] Suggestion: new 3 release with backwards compatibility

"Martin v. Löwis" martin at v.loewis.de
Tue Jan 5 22:07:23 CET 2010


> It's not even that easy -- libraries can't apply patches for Python 3
> compatibility as they usually break Python 2 compatibility.  Potentially
> libraries could apply patches that make a codebase 2to3 ready, but from
> what I've seen that's more black magic than straight forward updating,
> as such patches have to trick 2to3 producing the output that is desired.

I wouldn't qualify it in that way. It may be necessary occasionally to
trick 2to3, but that's really a bug in 2to3 which you should report, so
that trickery is then a work-around for a bug - something that you may
have to do with other API, as well.

The "black magic" is really more in the parts that 2to3 doesn't touch
at all (because they are inherently not syntactic); these are the
problem areas Guido refers to. The "black magic" then is to make the
same code work unmodified for both 2.x and 3.x.

> The only workable workflow I've seen people propose for maintaining a
> single codebase with compatibility across both 2 and 3 is to use such
> tricks, with aliases to suppress some 2to3 updates when they are
> inappropriate

I think you misunderstand. All this is necessary, but *not* to suppress
2to3 updates. More typically, it is necessary because 2to3 leaves the
code unmodified either way.

> Also, running 2to3 on installation is kind of annoying, as you get
> source that isn't itself the canonical source, so to fix bugs you have
> to look at the installed source and trace it back to the bug in the
> original source.

That's an issue indeed, but one that I would hope that can be fixed by
improved traceback printing. It would be good if such traceback printing
could make it into 2.7.

Regards,
Martin



More information about the Python-Dev mailing list