Version 2 (modified by Cas, 10 years ago) (diff)

add some more notes

Python 3 Port

This page provides more detailed information on porting to Python 3 started in ticket #1328.

The current consensus is that the core and common files should be prepared for a future Twisted release with full Python 3 support and UI's worked on at a later date.


It is best to read these other documents on Python 3 porting



Deluge relies on all dependant packages supporting Python 3 with twisted being the most crucial. At the time of writing there is minimal Python 3 support in Twisted >= 12.3 but work is still ongoing: Twisted Python 3 Plan.


Although 2to3 will highlight areas requiring changes it cannot be relied upon to make the correct decisions especially concerting bytes and unicode strings so do not commit code changes generated by it.

Also see a wrapper to 2to3 called python-modernize.

Required changes

  • Change from setuptools to distribute
  • Magic Method __cmp__ in replaced with __lt__
  • Found at least one instance of raise with three args in Blocklist plugin
  • in Blocklist plugin - Rename next() to __next__() and add next = __next__ to class
  • iteritems() where needed replace with try/except:

Future Imports

from __future__ import unicode_literals
Likely to be applied to all files to ensure byte, Unicode string separation
from __future__ import division and from __future__ import print_function
Added to files where required
from __future__ import absolute_import
Should not be required if the imports are properly set up. See:

Compatibility Module

It will be easier and simpler to use either six or pies to enable writing compatible code.