I'd prefer it if you separated it into `path_encode_py2` and `path_encode_py3` and then had the `if` statement just assign one of those to `path_encode`, rather than having large function definitions inside a conditional block.