Home

Summary

This is a work-in-progress, unofficial port of Twisted to Python 3. The strategy is:

  1. run 2to3 over the codebase
  2. fix code manually until tests pass, one test file at a time

Optionally, howtos and examples should also be fixed, to validate the approach on entire programs.

The changes done to the code are the smallest changes needed to make stuff work. The goal is to minimize the resulting diffs (they will still be big of course).

Check out

The port is done in the t3k branch, so make sure you update to it.

Dependencies

I use Python 3.2 to develop this project. Currently, I do not intend to support previous Python 3 versions.

Basic dependencies are zope.interface and distribute (distutils is not enough to install zope.interface on Python 3.)

For TLS/SSL support, pyOpenSSL is required.

For SSH support, PyCrypto 2.6 or later and pyasn1 0.1.4 or later are required. You can also install gmpy for faster big-number cryptography.

For Windows support, pywin32 is recommended.

Milestones

The first milestone is to make core Twisted work (twisted.python, twisted.internet, twisted.protocols, twisted.spread, twisted.trial). This is pretty much done.

The second milestone is to experiment with merging new changes from upstream. The necessary effort looks so far quite reasonable.

The third, pie-in-the-sky milestone is to make all of Twisted work.

Status

Twisted builds and installs fine, including the optional extension modules. You can use most of Twisted Core and also Names and Conch.

The following configurations were tested:

  • 64-bit Linux
  • 64-bit Windows 7 (including the IOCP reactor, but without pyOpenSSL)

The following tests pass:

  • All of twisted/application/test
  • All of twisted/conch/test
  • All of twisted/internet/test
  • All of twisted/lore/test
  • All of twisted/manhole/test
  • All of twisted/names/test
  • All of twisted/pair/test
  • All of twisted/protocols/test
  • All of twisted/python/test
  • All of twisted/runner/test
  • All of twisted/scripts/test
  • All of twisted/trial/test
  • All of twisted/test except test_hook, test_sip

The following scripts are known to work:

  • cftp
  • conch
  • trial
  • twistd

As a last resort, due to irreconcilable differences between Python 2 and 3, a couple of test cases have been marked "skipped" or "todo". They are very exceptional and don't affect overall functionality. The primary offenders are the semantic gap between old-style and new-style classes, and the fact that Python 3 doesn't have "unbound" methods (when you lookup a normal method on a class, you just get the original function without a __class__ attribute to tell you where it is attached).

Help

If you want to help, there are several possible tasks:

  • easy: take an existing example, run it and fix it (in general, this mostly requires making string literals into bytes literals)
  • ranging from easy to tricky: take a test that currently fails and fix code (in the test and/or the tested modules) so that it passes

Getting setup

First you'll need to build Twisted, for example using

python3 setup.py develop

Then running a test is a matter of

python3 bin/trial twisted.test.test_name

The trial test runner has many options, use the --help option for more information.

Decisions

I had to make the following decisions:

  • FilePath.open() gets an additional "encoding" argument
  • banana gets support for bytes objects using a separate opcode
  • an AMP box is now a dictionary of str keys mapping to bytes values

When conversion of strings from/to bytes is required, utf-8 is preferred as an encoding, although ascii is sometimes used for safety when parsing well-known datatypes. I also rely on os.fsencode() and os.fsdecode() where appropriate.

Updated

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.