Python 3 compatibility fixes

--HG--
extra : amend_source : 5ff782d49030e63465feb156bd5468d8856e5862