Implementation of pep 3143 for python 3