Adapt the python port to support python 3