Fix string input in legacy mode under Python 3.