[Twisted-Python] Helping the Python 3 port

Itamar Turner-Trauring itamar at itamarst.org
Wed May 8 11:00:16 MDT 2013


On 05/08/2013 10:30 AM, Jonathan Ballet wrote:
> Hi,
>
> I'm interested to give a help to port Twisted to Python 3.
> I gave a look at the tickets on Trac tagged with py3k and those in the
> Python-3.x milestone. I gave a try at
> http://twistedmatrix.com/trac/ticket/5802 to see what still needed to be
> done, and after rebasing the patch on trunk and starting to hack a few
> modules, I noticed that I have to do those 3 things in a bunch of
> places:
>
> * use the newer "except Exception as e" instead of "except Exception, e"
> * use the print function instead of the print statement
> * replace "implements(IFoo)" by the class decorator "@implementer(IFoo)"
>
> I can probably post a new patch which fixes all those things in order
> for Trial (as per #5802) to just start, but I wonder if this is the
> right approach and if it wouldn't be better to fix those first (since
> they are, AFAIK, compatible with Python 2.6 anyway).
>
You can definitely do these as a patch on their own, but try not to do 
too many modules at once so that the patch is manageable for review. The 
process for Python 3 ports is getting the tests for a module running 
correctly on Python 3, and then making them pass. Past efforts to port 
to Python 3 have foundered on things like:

 1. Not bothering to make the tests work the same way on Python 2. You
    /must not/ change APIs from Python 2's point of view as part of a
    Python 3 port.
 2. Randomly changing bytes to unicode with no thought about which is
    correct.
 3. Lack of test coverage. Old code doesn't have enough tests, so you
    sometimes need to add tests and only then do the port.





More information about the Twisted-Python mailing list