以下来自 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's standard str()
# output should be.
s = u' '.join([force_unicode(arg, encoding, strings_only,
errors) for arg in s])
我的问题是:在哪种情况下会s
出现异常?
当 s 是 Exception 的一个实例,并且 s 既没有 str 也没有 repr 属性。比这种情况发生。这是正确的吗?