In Python 3, both parse_qs and urlencode are in urllib.parse [1,2].
In Python 2, parse_qs is in urlparse and urlencode is in urllib [3,4].
Get consistent Python-3-compatible naming by stuffing urlencode into
our _urllib_parse namespace.
[1]: https://docs.python.org/2/library/urlparse.html#urlparse.parse_qs
[2]: https://docs.python.org/2/library/urllib.html#urllib.urlencode
[3]: https://docs.python.org/3/library/urllib.parse.html#urllib.parse.parse_qs
[4]: https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urlencode
import urllib.parse as _urllib_parse
except ImportError: # Python 2
import urlparse as _urllib_parse
+ import urllib as _urllib
+ _urllib_parse.urlencode = _urllib.urlencode
import xml.sax.saxutils as _xml_sax_saxutils