Use text_type instead of str to handle unicode.