1 from __future__
import absolute_import
, division
, unicode_literals
5 import urllib2
as parse
8 from urllib
import parse
11 PY2
= sys
.version_info
[0] == 2
12 PY3
= sys
.version_info
[0] >= 3
13 PY26_PLUS
= PY2
and sys
.version_info
[1] >= 6
14 WIN32
= sys
.platform
== 'win32' or sys
.platform
== 'cygwin'
18 # pylint: disable=bytes-builtin
19 return bytes(x
, encoding
='utf8')
21 # pylint: disable=bytes-builtin
38 # pylint: disable=unicode-builtin
40 # pylint: disable=unichr-builtin
42 int_types
= (int, long) # pylint: disable=long-builtin
45 def setenv(key
, value
):
46 """Compatibility wrapper for setting environment variables
48 Why? win32 requires putenv(). UNIX only requires os.environ.
51 if not PY3
and type(value
) is ustr
:
52 value
= value
.encode('utf-8', 'replace')
53 os
.environ
[key
] = value
58 """Compatibility wrapper for unsetting environment variables"""
63 if hasattr(os
, 'unsetenv'):