On Python3, these would be text strings already. On Python2, we need to convert them from bytes. Use a new helper function py3compat to do this. Fixes #43207