Fix python3-specific handling of strings