Below is the source code for django ( Django-1.41/django/utils/encoding.py );
try: s = unicode(str(s), encoding, errors) except UnicodeEncodeError: if not isinstance(s, Exception): raise # If we get to here, the caller has passed in an Exception # subclass populated with non-ASCII data without special # handling to display as a string. We need to handle this # without raising a further exception. We do an # approximation to what the Exception standard str() # output should be. s = u' '.join([force_unicode(arg, encoding, strings_only, errors) for arg in s])
My question is: in which case s will be an instance of Exception?
when s is an instance of Exception and s does not have the str or repr attribute. How does this situation happen. Is it correct?
Yejing
source share