def correct_encoding_for_envvars(value):
try:<EOL><INDENT>str(value)<EOL><DEDENT>except UnicodeEncodeError:<EOL><INDENT>value = value.encode('<STR_LIT:utf8>')<EOL><DEDENT>return value<EOL>
Env vars are unicode in Python 3 but bytes in Python 2