summaryrefslogtreecommitdiff
path: root/paste/url.py
diff options
context:
space:
mode:
authorCyril Roelandt <cyril.roelandt@enovance.com>2014-03-18 12:49:12 +0100
committerCyril Roelandt <cyril.roelandt@enovance.com>2014-03-18 12:49:12 +0100
commit674ae7718bc06a8b8c8b658075bf82c8198fb632 (patch)
tree0075bace24ead7f03ae7cb18935e4c707f71a860 /paste/url.py
parent3cdb7e4227cbaad690b1c1557c03fa6da0decc36 (diff)
downloadpaste-674ae7718bc06a8b8c8b658075bf82c8198fb632.tar.gz
Python 3: use new names of standard library modules
Use "try/except ImportError" to try Python 2 and Python 3 names.
Diffstat (limited to 'paste/url.py')
-rw-r--r--paste/url.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/paste/url.py b/paste/url.py
index afc4fca..87a6e8a 100644
--- a/paste/url.py
+++ b/paste/url.py
@@ -4,7 +4,7 @@
"""
This module implements a class for handling URLs.
"""
-import urllib
+from six.moves.urllib.parse import quote, unquote, urlencode
import cgi
from paste import request
# Imported lazily from FormEncode:
@@ -20,9 +20,7 @@ def html_quote(v):
def url_quote(v):
if v is None:
return ''
- return urllib.quote(str(v))
-
-url_unquote = urllib.unquote
+ return quote(str(v))
def js_repr(v):
if v is None:
@@ -102,7 +100,7 @@ class URLResource(object):
def __getitem__(self, item):
if '=' in item:
name, value = item.split('=', 1)
- return self._add_vars({url_unquote(name): url_unquote(value)})
+ return self._add_vars({unquote(name): unquote(value)})
return self._add_positional((item,))
def attr(self, **kw):
@@ -202,7 +200,7 @@ class URLResource(object):
elif val is None:
continue
vars.append((name, val))
- s += urllib.urlencode(vars, True)
+ s += urlencode(vars, True)
return s
href = property(href__get)