1 # pylint: disable=unused-import,redefined-builtin,undefined-variable
2 from __future__
import absolute_import
, division
, unicode_literals
6 import urllib2
as parse
# noqa
9 from urllib
import parse
# noqa
13 from collections
import OrderedDict
as odict
# noqa
15 from .ordered_dict
import OrderedDict
as odict
# noqa
18 PY2
= sys
.version_info
[0] == 2
19 PY3
= sys
.version_info
[0] >= 3
20 PY26_PLUS
= PY2
and sys
.version_info
[1] >= 6
21 WIN32
= sys
.platform
== 'win32' or sys
.platform
== 'cygwin'
26 def bstr(x
, encoding
=ENCODING
):
27 return bytes(x
, encoding
=encoding
)
46 # pylint: disable=unicode-builtin
48 # pylint: disable=unichr-builtin
50 # pylint: disable=long-builtin
51 int_types
= (int, long) # noqa
54 def setenv(key
, value
):
55 """Compatibility wrapper for setting environment variables
57 Why? win32 requires putenv(). UNIX only requires os.environ.
60 if not PY3
and isinstance(value
, ustr
):
61 value
= value
.encode(ENCODING
, 'replace')
62 os
.environ
[key
] = value
67 """Compatibility wrapper for unsetting environment variables"""
72 if hasattr(os
, 'unsetenv'):