summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/news.txt2
-rw-r--r--paste/httpexceptions.py16
2 files changed, 11 insertions, 7 deletions
diff --git a/docs/news.txt b/docs/news.txt
index 7561617..e41b07a 100644
--- a/docs/news.txt
+++ b/docs/news.txt
@@ -24,6 +24,8 @@ svn trunk
* In :class:`paste.proxy.Proxy` handle Content-Length of -1.
+* In :mod:`paste.httpexceptions` avoid some unicode errors.
+
1.7.2
-----
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):