gallery.py: Python-3-compatible parse_qs import
[blog.git] / posts / gallery / gallery.py
index 1a3c958753c0093460e7e561c67c59227cfc88d5..b97835ca52f4df32e4cfcd8339462bfbef91e26d 100755 (executable)
@@ -51,7 +51,10 @@ import os.path as _os_path
 import random as _random
 import re as _re
 import subprocess as _subprocess
-import urlparse as _urlparse
+try:  # Python 3
+    import urllib.parse as _urllib_parse
+except ImportError:  # Python 2
+    import urlparse as _urllib_parse
 import xml.sax.saxutils as _xml_sax_saxutils
 
 
@@ -246,7 +249,7 @@ class CGIGalleryServer (object):
         Specify either query or query_string, but not both.
         """
         if query is None:
-            query = _urlparse.parse_qs(query_string)
+            query = _urllib_parse.parse_qs(query_string)
         page = 0
         if 'pp' in query:
             pp = query['pp']