Changeset 4522
- Timestamp:
- 02/14/07 22:13:02 (2 years ago)
- Files:
-
- django/trunk/django/newforms/util.py (modified) (1 diff)
- django/trunk/tests/regressiontests/forms/tests.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/newforms/util.py
r4370 r4522 8 8 def smart_unicode(s): 9 9 if not isinstance(s, basestring): 10 s = unicode(str(s)) 10 if hasattr(s, '__unicode__'): 11 s = unicode(s) 12 else: 13 s = unicode(str(s), settings.DEFAULT_CHARSET) 11 14 elif not isinstance(s, unicode): 12 15 s = unicode(s, settings.DEFAULT_CHARSET) django/trunk/tests/regressiontests/forms/tests.py
r4521 r4522 3266 3266 >>> f.clean('') 3267 3267 u'' 3268 3269 ################################# 3270 # Tests of underlying functions # 3271 ################################# 3272 3273 # smart_unicode tests 3274 >>> from django.newforms.util import smart_unicode 3275 >>> class Test: 3276 ... def __str__(self): 3277 ... return 'ŠĐĆŽćžšđ' 3278 >>> class TestU: 3279 ... def __str__(self): 3280 ... return 'Foo' 3281 ... def __unicode__(self): 3282 ... return u'\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111' 3283 >>> smart_unicode(Test()) 3284 u'\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111' 3285 >>> smart_unicode(TestU()) 3286 u'\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111' 3287 >>> smart_unicode(1) 3288 u'1' 3289 >>> smart_unicode('foo') 3290 u'foo' 3268 3291 """ 3269 3292
