From: W. Trevor King Date: Sat, 29 Sep 2012 12:44:00 +0000 (-0400) Subject: scgi-test: convert urlparse -> urllib.parse for Python 3. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=77c53a9d8ac8f24314b63659e05d0066d40a3a54;p=blog.git scgi-test: convert urlparse -> urllib.parse for Python 3. --- diff --git a/posts/SCGI/scgi-test.py b/posts/SCGI/scgi-test.py index e521f53..4f6ea3d 100755 --- a/posts/SCGI/scgi-test.py +++ b/posts/SCGI/scgi-test.py @@ -20,7 +20,10 @@ """ import socket as _socket -import urlparse as _urlparse +try: # Python 3 + import urllib.parse as _urllib_parse +except ImportError: # Python 2 + import urlparse as _urllib_parse __version__ = '0.1' @@ -66,10 +69,10 @@ def header(method, uri, data=None): # as $request_uri is what was originally sent by the browser # before any such modifications. Does not include the protocol # or host name. Example: /foo/bar.html - scheme,netloc,path,params,query,fragment = _urlparse.urlparse(uri) + scheme,netloc,path,params,query,fragment = _urllib_parse.urlparse(uri) # :///;?# scheme = netloc = '' - request_uri = _urlparse.urlunparse( + request_uri = _urllib_parse.urlunparse( (scheme, netloc, path, params, query, fragment)) document_uri = path strings = [