If the item is not a text_type it should always be bytes, so you can just remove the str() call in the else branch.