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/encoding.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/encoding.py')
| -rw-r--r-- | django/utils/encoding.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/django/utils/encoding.py b/django/utils/encoding.py index 789e709da5..f2295444bf 100644 --- a/django/utils/encoding.py +++ b/django/utils/encoding.py @@ -1,10 +1,13 @@ from __future__ import unicode_literals -import urllib -import locale -import datetime import codecs +import datetime from decimal import Decimal +import locale +try: + from urllib.parse import quote +except ImportError: # Python 2 + from urllib import quote from django.utils.functional import Promise from django.utils import six @@ -165,7 +168,7 @@ def iri_to_uri(iri): # converted. if iri is None: return iri - return urllib.quote(smart_str(iri), safe=b"/#%[]=:;$&()+,!?*@'~") + return quote(smart_str(iri), safe=b"/#%[]=:;$&()+,!?*@'~") def filepath_to_uri(path): """Convert an file system path to a URI portion that is suitable for @@ -184,7 +187,7 @@ def filepath_to_uri(path): return path # I know about `os.sep` and `os.altsep` but I want to leave # some flexibility for hardcoding separators. - return urllib.quote(smart_str(path).replace("\\", "/"), safe=b"/~!*()'") + return quote(smart_str(path).replace("\\", "/"), safe=b"/~!*()'") # The encoding of the default system locale but falls back to the # given fallback encoding if the encoding is unsupported by python or could |
