2

I want to port a web application scanning framework from Python 2.6.5-2.7.3 to Python 3 without causing much harm to the compatibility with Python 2.6+.

I have read briefly about six: Python 2 and 3 Compatibility Library and python-modernize.

The framework I am intending to port uses libraries like twisted which are natively supported in Python 2. I have read http://twistedmatrix.com/trac/wiki/Plan/Python3 which warns against usage of 2to3 at any stage during this process.
The fact that python-modernize is a version of 2to3 has been another source of confusion.

May I have some suggesions on the optimal approach to carry out such a porting and some common bugs that I might encounter ?

  • 1
    I found this very useful when I was porting: http://docs.python.org/3/howto/pyporting.html – Tejas Pendse Mar 18 '14 at 14:04
  • `python-modernize` produces Python 2 code that should also work on Python 3. You could use it if you want to support both Python 2 and 3 from the same codebase (as twisted does). Presumably, you should call it manually unlike 2to3 that may be called automatically by `setup.py`. – jfs Mar 18 '14 at 14:20
  • The thing to be more concerned about is whether or not any of your dependencies (the greater the number, the more likely) are incompatible with Python 3. Many libraries will `pip install` successfully in Python 3, but have things like `except SomeError, exc:` (not compatible), etc. For instance, I just tried to use Python 3 in Heroku with Gunicorn and eventlet... no dice. – orokusaki Mar 18 '14 at 14:33
  • @Ffisegydd Thanks for pointing out. I have edited my post accordingly. – Akshay Krishnan R Mar 18 '14 at 15:40
  • This is a very broad question. "May I have some suggesions [sic] on the optimal approach to carry out such a porting and some common bugs that I might encounter ?" – George Stocker Mar 18 '14 at 20:17
  • I had this question and per today's research think that the best forward and backward compatible solution, which is apparently so easy for new code is: 1.pip install future ; 2.Include: from __future__ import (absolute_import, division, print_function, unicode_literals) ; from builtins import * ; 3. Write standard Python 3 code. ; 4.Per the Quick-start guide — Python-Future documentation ; http://python-future.org/quickstart.html – AnneTheAgile Jan 19 '15 at 02:35

0 Answers0