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

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 and support is just about complete: Twisted Python 3 Plan.

Another option for Twisted is to remove the use of it in favour of Python 3's asyncio. This would, of course, remove backwards compatibility with Python 2 and require a lot of work to port to asyncio, but could be worthwhile in the end.

2to3

Using python-future is the best option to convert the code.

Required changes

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 future or six (see py-future docs) to write compatible code.

Last modified 7 years ago Last modified on 10/26/2016 09:10:14 AM