[Twisted-Python] Porting Twisted to Python 3.

Itamar Turner-Trauring itamar at itamarst.org
Tue May 20 04:50:13 MDT 2014


On 05/20/2014 05:40 AM, Maxim Lacrima wrote:
> Hello!
>
> I can see that Python 3 support in Twisted is incomplete. I was able 
> to `pip install twisted` on Python 3, but I couldn't run a simple 
> example program using Twisted Agent.
>
> A simple `from twisted.web.client import Agent` causes `ImportError: 
> No module named 'twisted.python.systemd'`
>
> I would like to help in porting Twisted to Python 3. I have a couple 
> of questions.
>
> My initial idea was to run some twisted tests with trial and start 
> from there. But it looks like trial is not ported to python3 and also 
> I think many tests themselves are not python3 aware.

The trial command-line tool is not ported, but the library part is.

admin/run-python3-tests 
<https://twistedmatrix.com/trac/browser/trunk/admin/run-python3-tests> 
will run Twisted's tests on Python 3.

> So what is a recommended workflow?
>

See https://twistedmatrix.com/trac/wiki/Plan/Python3

> As for Twisted Agent... URL and its parsed components are now bytes, 
> but `Agent._getEndpoint` operates on str, and so do other functions 
> (`isIPAddress`, `isIPv6Address`), causing type and other errors.

Probably Agent would probably need to be modified to explicitly take 
bytes on both Python 2 and Python 3, since URLs are bytes.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20140520/b83a1865/attachment-0002.html>


More information about the Twisted-Python mailing list