= 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. == References == It is best to read these other documents on Python 3 porting [https://docs.djangoproject.com/en/dev/topics/python3/ Django] [https://wiki.ubuntu.com/Python/3] [https://twistedmatrix.com/trac/wiki/Plan/Python3] == Twisted == 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: [https://twistedmatrix.com/trac/wiki/Plan/Python3 Twisted Python 3 Plan]. == 2to3 == 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 setup.py from `setuptools` to `distribute` * Magic Method `__cmp__` in `common.py` replaced with `__lt__` * Found at least one instance of raise with three args in Blocklist plugin * peerguardian.py in Blocklist plugin - Rename `next()` to `__next__()` and add `next = __next__` to class * `iteritems()` where needed replace with try/except: http://python3porting.com/differences.html#dictionary-methods == 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: http://python3porting.com/differences.html#imports == Compatibility Module == It will be easier and simpler to use either `six` or `pies` to enable writing compatible code.