diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-07-20 15:36:52 +0200 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-07-22 09:29:55 +0200 |
| commit | 0d914d08a0d7b5a1521f498a8047971fe6cd61e7 (patch) | |
| tree | d0ab08b0b5b2041bd796c10a26a358ae60d0914a /django/utils/html.py | |
| parent | bdca5ea345c548a82a80d198906818c9ccbef896 (diff) | |
[py3] Updated urllib/urllib2/urlparse imports.
Lots of functions were moved. Use explicit imports in all cases
to keey it easy to identify where the functions come from.
Diffstat (limited to 'django/utils/html.py')
| -rw-r--r-- | django/utils/html.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/django/utils/html.py b/django/utils/html.py index d5881996d9..7e35fdecb8 100644 --- a/django/utils/html.py +++ b/django/utils/html.py @@ -4,8 +4,11 @@ from __future__ import unicode_literals import re import string -import urllib -import urlparse +try: + from urllib.parse import quote, urlsplit, urlunsplit +except ImportError: # Python 2 + from urllib import quote + from urlparse import urlsplit, urlunsplit from django.utils.safestring import SafeData, mark_safe from django.utils.encoding import smart_str, force_unicode @@ -138,19 +141,19 @@ fix_ampersands = allow_lazy(fix_ampersands, six.text_type) def smart_urlquote(url): "Quotes a URL if it isn't already quoted." # Handle IDN before quoting. - scheme, netloc, path, query, fragment = urlparse.urlsplit(url) + scheme, netloc, path, query, fragment = urlsplit(url) try: netloc = netloc.encode('idna') # IDN -> ACE except UnicodeError: # invalid domain part pass else: - url = urlparse.urlunsplit((scheme, netloc, path, query, fragment)) + url = urlunsplit((scheme, netloc, path, query, fragment)) # An URL is considered unquoted if it contains no % characters or # contains a % not followed by two hexadecimal digits. See #9655. if '%' not in url or unquoted_percents_re.search(url): # See http://bugs.python.org/issue2637 - url = urllib.quote(smart_str(url), safe=b'!*\'();:@&=+$,/?#[]~') + url = quote(smart_str(url), safe=b'!*\'();:@&=+$,/?#[]~') return force_unicode(url) |
