[Python-Dev] Spreading the Python 3 religion
Barry Warsaw
barry at python.org
Thu Mar 1 17:24:19 CET 2012
On Mar 01, 2012, at 04:42 PM, Antoine Pitrou wrote:
>Well, to be honest, "making good progress" currently means "bored and
>not progressing at all" :-) But that's not due to the strategy I
>adopted, only to the sheer amount of small changes needed, and lack of
>immediate motivation to continue this work.
For any porting strategy, the best thing to do is to get as many changes into
upstream as possible that prepares the way for Python 3 support. For example,
when I did the dbus-python port, upstream (rightly so) rejected my big
all-together-now patch.
Instead, we took a number of smaller steps, many of which were incorporated
before the Python 3 support landed. These included:
- Agreeing to Python 2.6 as a minimum base
- #include <byteobject.h> and global PyString_* -> PyBytes_* conversion
- (yes) adding future imports for unicode_literals, unadorning unicodes and
adding b'' prefixes where necessary
- fixing except clauses to use 'as'
- removing L suffix on integer literals
- lots of other little syntactic nits
You could add to that things like print functions (although IIRC dbus-python
had few if any of these), etc. So really, it was the same strategy as any
porting process, but the key was breaking these up into reviewable chunks that
could be applied while still keeping the code base Python 2 only.
I really do think that to the extent that you can do that kind of thing, you
may end up with essentially Python 3 support without even realizing it. :)
Cheers,
-Barry
More information about the Python-Dev
mailing list