-import urllib
-import urlparse
-
-if hasattr(urlparse, 'parse_qs'):
- parse_qs = urlparse.parse_qs
-else:
- # Python <2.6 compatibility
- from cgi import parse_qs
+try:
+ from urllib.parse import urlencode, urlparse, parse_qs, ParseResult
+except ImportError:
+ from urllib import urlencode
+ from urlparse import urlparse, ParseResult
+ from urlparse import parse_qs