summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-04-22 00:04:53 +0200
committerVictor Stinner <victor.stinner@gmail.com>2015-04-22 00:04:53 +0200
commit941e410ee90e6f87cf35ce7a3d5da0aa90c447d6 (patch)
tree3963425d7ae1c1e975d55305699474775cffa0ad
parent6b013060ce394c38a7f7a902d17c4c9a082a3df8 (diff)
downloadpaste-git-941e410ee90e6f87cf35ce7a3d5da0aa90c447d6.tar.gz
Fix cgitb_catcher on Python 3
-rw-r--r--paste/cgitb_catcher.py4
-rw-r--r--tests/test_cgitb_catcher.py7
2 files changed, 9 insertions, 2 deletions
diff --git a/paste/cgitb_catcher.py b/paste/cgitb_catcher.py
index 3185506..f88ffb8 100644
--- a/paste/cgitb_catcher.py
+++ b/paste/cgitb_catcher.py
@@ -49,6 +49,8 @@ class CgitbMiddleware(object):
[('content-type', 'text/html')],
exc_info)
response = self.exception_handler(exc_info, environ)
+ if six.PY3:
+ response = response.encode('utf8')
return [response]
def catching_iter(self, app_iter, environ):
@@ -72,6 +74,8 @@ class CgitbMiddleware(object):
response += (
'<hr noshade>Error in .close():<br>%s'
% close_response)
+ if six.PY3:
+ response = response.encode('utf8')
yield response
def exception_handler(self, exc_info, environ):
diff --git a/tests/test_cgitb_catcher.py b/tests/test_cgitb_catcher.py
index c2c6632..a63f7d8 100644
--- a/tests/test_cgitb_catcher.py
+++ b/tests/test_cgitb_catcher.py
@@ -31,7 +31,7 @@ def after_start_response_app(environ, start_response):
def iter_app(environ, start_response):
start_response("200 OK", [('Content-type', 'text/plain')])
- return yielder(['this', ' is ', ' a', None])
+ return yielder([b'this', b' is ', b' a', None])
def yielder(args):
for arg in args:
@@ -46,7 +46,10 @@ def yielder(args):
def test_makes_exception():
res = do_request(bad_app)
print(res)
- assert 'bad_app() takes no arguments (2 given' in res
+ if six.PY3:
+ assert 'bad_app() takes 0 positional arguments but 2 were given' in res
+ else:
+ assert 'bad_app() takes no arguments (2 given' in res
assert 'iterator = application(environ, start_response_wrapper)' in res
assert 'lint.py' in res
assert 'cgitb_catcher.py' in res