Fixed a regression bug from python2 to python3 conversion.