Merge client environ setup from Django master

I have noticed and compared it because of flake8 issues, and the only
non-whitespace changes are the addition of `str()` and `b''` wrappers.