Changeset 8588
- Timestamp:
- 08/26/08 13:53:51 (3 months ago)
- Files:
-
- django/trunk/django/utils/encoding.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/utils/encoding.py
r8046 r8588 49 49 s = unicode(s) 50 50 else: 51 s = unicode(str(s), encoding, errors) 51 try: 52 s = unicode(str(s), encoding, errors) 53 except UnicodeEncodeError: 54 if not isinstance(s, Exception): 55 raise 56 # If we get to here, the caller has passed in an Exception 57 # subclass populated with non-ASCII data without special 58 # handling to display as a string. We need to handle this 59 # without raising a further exception. We do an 60 # approximation to what the Exception's standard str() 61 # output should be. 62 s = ' '.join([force_unicode(arg, encoding, strings_only, 63 errors) for arg in s]) 52 64 elif not isinstance(s, unicode): 53 65 # Note: We use .decode() here, instead of unicode(s, encoding, … … 73 85 return str(s) 74 86 except UnicodeEncodeError: 87 if isinstance(s, Exception): 88 # An Exception subclass containing non-ASCII data that doesn't 89 # know how to print itself properly. We shouldn't raise a 90 # further exception. 91 return ' '.join([smart_str(arg, encoding, strings_only, 92 errors) for arg in s]) 75 93 return unicode(s).encode(encoding, errors) 76 94 elif isinstance(s, unicode):
