Commit 69389d5c authored by 's avatar

- fixed handling of exceptions with unicode values

parent d7d17593
......@@ -795,7 +795,10 @@ class HTTPResponse(BaseResponse):
b = v
if isinstance(b, Exception):
try:
b = str(b)
try:
b = str(b)
except UnicodeEncodeError:
b = self._encode_unicode(unicode(b))
except:
b = '<unprintable %s object>' % type(b).__name__
......
......@@ -147,6 +147,29 @@ Handle zExceptions.Unauthorized raised by the object. We take the
Unauthorized: ERROR VALUE
>>> browser.contents
And the same with unicode error value.
>>> app.test_folder_1_.foo.exception = Unauthorized(u'ERROR VALUE \u03A9')
>>> browser.handleErrors = True
>>> browser.open('http://localhost/test_folder_1_/foo')
Traceback (most recent call last):
...
HTTPError: HTTP Error 401: Unauthorized
>>> 'Error Type: Unauthorized' in browser.contents
True
>>> 'Error Value: ERROR VALUE ?' in browser.contents
True
>>> browser.headers['WWW-Authenticate']
'basic realm="Zope2"'
>>> browser.handleErrors = False
>>> browser.open('http://localhost/test_folder_1_/foo')
Traceback (most recent call last):
...
Unauthorized: <unprintable ... object>
>>> browser.contents
Handle zExceptions.Unauthorized raised by BaseRequest.traverse. We take the
'WWW-Authenticate' header as a sign that HTTPResponse._unauthorized was called.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment