From: W. Trevor King Date: Thu, 14 Aug 2014 23:15:35 +0000 (-0700) Subject: gallery.py: Shift urlencode into the _urllib_parse namespace for Python 2 X-Git-Url: http://git.tremily.us/?p=blog.git;a=commitdiff_plain;h=8fa75afba68c971e5cbc83c8242dce436e3ec95d gallery.py: Shift urlencode into the _urllib_parse namespace for Python 2 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 --- diff --git a/posts/gallery/gallery.py b/posts/gallery/gallery.py index 4be733b..3b3ed1d 100755 --- a/posts/gallery/gallery.py +++ b/posts/gallery/gallery.py @@ -57,6 +57,8 @@ try: # Python 3 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