summaryrefslogtreecommitdiff
path: root/paste/httpexceptions.py
diff options
context:
space:
mode:
authorianb <devnull@localhost>2009-04-24 20:16:18 +0000
committerianb <devnull@localhost>2009-04-24 20:16:18 +0000
commitd2db9c36d8ed2cd559e87bb0020672927cc1de14 (patch)
tree1790951144ca1ef1b97eca79aad9e8be2913d1be /paste/httpexceptions.py
parent608be9fa2ca93d0122bb7d3ab39ed6e078ee0b4d (diff)
downloadpaste-d2db9c36d8ed2cd559e87bb0020672927cc1de14.tar.gz
Avoid some unicode errors in httpexceptions
Diffstat (limited to 'paste/httpexceptions.py')
-rw-r--r--paste/httpexceptions.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/paste/httpexceptions.py b/paste/httpexceptions.py
index b14ad5a..82ad1b0 100644
--- a/paste/httpexceptions.py
+++ b/paste/httpexceptions.py
@@ -199,13 +199,15 @@ class HTTPException(Exception):
args = {'explanation': escfunc(self.explanation),
'detail': escfunc(self.detail),
'comment': comment_escfunc(self.comment)}
- if HTTPException.template == self.template:
- return template % args
- for (k, v) in environ.items():
- args[k] = escfunc(v)
- if self.headers:
- for (k, v) in self.headers:
- args[k.lower()] = escfunc(v)
+ if HTTPException.template != self.template:
+ for (k, v) in environ.items():
+ args[k] = escfunc(v)
+ if self.headers:
+ for (k, v) in self.headers:
+ args[k.lower()] = escfunc(v)
+ for key, value in args.items():
+ if isinstance(value, unicode):
+ args[key] = value.encode('ascii', 'utf8')
return template % args
def plain(self, environ):