Commit 4d31853c authored by 's avatar

- fixed handling of exceptions with unicode values

parent aa6b8b78
......@@ -55,6 +55,8 @@ Features Added
Bugs Fixed
++++++++++
- HTTPResponse: Fixed handling of exceptions with unicode values.
- zExceptions: Fixed some unicode issues in Unauthorized.
- LP #372632, comments #15ff.: Fixed regression in Unauthorized handling.
......
......@@ -800,7 +800,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__
......
......@@ -140,6 +140,28 @@ Handle zExceptions.Unauthorized raised by the object. We take the
...
Unauthorized: ERROR VALUE
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>
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