Skip to content

Commit

Permalink
unicode: Changed handling of None in smart_unicode/force_unicode. The…
Browse files Browse the repository at this point in the history
…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
malcolmt committed May 31, 2007
1 parent 8d1ce1f commit 790d9ec
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions django/utils/encoding.py
Expand Up @@ -27,6 +27,8 @@ def force_unicode(s, encoding='utf-8', errors='strict'):
Similar to smart_unicode, except that lazy instances are resolved to Similar to smart_unicode, except that lazy instances are resolved to
strings, rather than kept as lazy objects. strings, rather than kept as lazy objects.
""" """
if s is None:
return s
if not isinstance(s, basestring,): if not isinstance(s, basestring,):
if hasattr(s, '__unicode__'): if hasattr(s, '__unicode__'):
s = unicode(s) s = unicode(s)
Expand Down Expand Up @@ -72,5 +74,7 @@ def iri_to_uri(iri):
# The list of safe characters here is constructed from the printable ASCII # 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 # characters that are not explicitly excluded by the list at the end of
# section 3.1 of RFC 3987. # section 3.1 of RFC 3987.
if iri is None:
return iri
return urllib.quote(smart_str(iri), safe='/#%[]=:;$&()+,!?') return urllib.quote(smart_str(iri), safe='/#%[]=:;$&()+,!?')


0 comments on commit 790d9ec

Please sign in to comment.