`parts` is a list of unicode strings, so you shouldn't join it on a bytestring.