summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-05-31 09:03:29 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-05-31 09:03:29 +0000
commit790d9ecf6706a82835151052b12c953021dcd90a (patch)
treed555ff2bc81f8dea77306606609fef08c2918069
parent8d1ce1fd334e29e676957d49182f4c47d7e9db79 (diff)
downloaddjango-790d9ecf6706a82835151052b12c953021dcd90a.tar.gz
unicode: Changed handling of None in smart_unicode/force_unicode. There is no
case when converting it to a unicode string seems useful, so keep it as None. Fixed #4435. git-svn-id: http://code.djangoproject.com/svn/django/branches/unicode@5388 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/utils/encoding.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/django/utils/encoding.py b/django/utils/encoding.py
index 8601dc44f3..2fe6a2d970 100644
--- a/django/utils/encoding.py
+++ b/django/utils/encoding.py
@@ -27,6 +27,8 @@ def force_unicode(s, encoding='utf-8', errors='strict'):
Similar to smart_unicode, except that lazy instances are resolved to
strings, rather than kept as lazy objects.
"""
+ if s is None:
+ return s
if not isinstance(s, basestring,):
if hasattr(s, '__unicode__'):
s = unicode(s)
@@ -72,5 +74,7 @@ def iri_to_uri(iri):
# The list of safe characters here is constructed from the printable ASCII
# characters that are not explicitly excluded by the list at the end of
# section 3.1 of RFC 3987.
+ if iri is None:
+ return iri
return urllib.quote(smart_str(iri), safe='/#%[]=:;$&()+,!?')