Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

unicode: Changed handling of None in smart_unicode/force_unicode. The…

…re 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
  • Loading branch information...
commit 790d9ecf6706a82835151052b12c953021dcd90a 1 parent 8d1ce1f
Malcolm Tredinnick authored May 31, 2007

Showing 1 changed file with 4 additions and 0 deletions. Show diff stats Hide diff stats

  1. 4  django/utils/encoding.py
4  django/utils/encoding.py
@@ -27,6 +27,8 @@ def force_unicode(s, encoding='utf-8', errors='strict'):
27 27
     Similar to smart_unicode, except that lazy instances are resolved to
28 28
     strings, rather than kept as lazy objects.
29 29
     """
  30
+    if s is None:
  31
+        return s
30 32
     if not isinstance(s, basestring,):
31 33
         if hasattr(s, '__unicode__'):
32 34
             s = unicode(s)
@@ -72,5 +74,7 @@ def iri_to_uri(iri):
72 74
     # The list of safe characters here is constructed from the printable ASCII
73 75
     # characters that are not explicitly excluded by the list at the end of
74 76
     # section 3.1 of RFC 3987.
  77
+    if iri is None:
  78
+        return iri
75 79
     return urllib.quote(smart_str(iri), safe='/#%[]=:;$&()+,!?')
76 80
 

0 notes on commit 790d9ec

Please sign in to comment.
Something went wrong with that request. Please try again.