From: W. Trevor King Date: Mon, 9 Dec 2013 04:37:05 +0000 (-0800) Subject: gallery.py: Python-3-compatible parse_qs import X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4b593b735d022d7a0bdf8e0119fc7209eaabb3d1;p=blog.git gallery.py: Python-3-compatible parse_qs import Python 2's urlparse.parse_qs moved to urllib.parse.parse_qs in Python 3. --- diff --git a/posts/gallery/gallery.py b/posts/gallery/gallery.py index 1a3c958..b97835c 100755 --- a/posts/gallery/gallery.py +++ b/posts/gallery/gallery.py @@ -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']