Maybe we can change this to use `str.encode`. @cyx wdyt?