gallery.py: Shift urlencode into the _urllib_parse namespace for Python 2
authorW. Trevor King <wking@tremily.us>
Thu, 14 Aug 2014 23:15:35 +0000 (16:15 -0700)
committerW. Trevor King <wking@tremily.us>
Thu, 14 Aug 2014 23:26:08 +0000 (16:26 -0700)
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

posts/gallery/gallery.py

index 4be733b60ecb8f9ea7138650e91fb996bdca7387..3b3ed1df22fd4bd1d9f296521ac7102b5b337746 100755 (executable)
@@ -57,6 +57,8 @@ try:  # Python 3
     import urllib.parse as _urllib_parse
 except ImportError:  # Python 2
     import urlparse as _urllib_parse
     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
 
 
 import xml.sax.saxutils as _xml_sax_saxutils