Code

Ticket #3314: form_utils.diff

File form_utils.diff, 590 bytes (added by nesh <nesh [at] studioquattro [dot] co [dot] yu>, 7 years ago)

smart_unicode patch

Line 
1Index: /www-libs/django/django/newforms/util.py
2===================================================================
3--- /www-libs/django/django/newforms/util.py    (revision 4451)
4+++ /www-libs/django/django/newforms/util.py    (working copy)
5@@ -7,7 +7,10 @@
6 
7 def smart_unicode(s):
8     if not isinstance(s, basestring):
9-        s = unicode(str(s))
10+        if hasattr(s, '__unicode__'):
11+            s = unicode(s)
12+        else:
13+            s = unicode(str(s), settings.DEFAULT_CHARSET)
14     elif not isinstance(s, unicode):
15         s = unicode(s, settings.DEFAULT_CHARSET)
16     return s