summaryrefslogtreecommitdiff
path: root/paste/httpexceptions.py
diff options
context:
space:
mode:
authorCyril Roelandt <cyril.roelandt@enovance.com>2014-03-18 12:47:02 +0100
committerCyril Roelandt <cyril.roelandt@enovance.com>2014-03-18 12:47:02 +0100
commit4262b41da195cb959abf4a5a06ce34a6dec2c4a3 (patch)
treecb6a9ef83ac83e6e6e0a90dd48ad9672b4e32a9d /paste/httpexceptions.py
parent3f98341a08e2899fdf6914776198bd0878e4f5c2 (diff)
downloadpaste-4262b41da195cb959abf4a5a06ce34a6dec2c4a3.tar.gz
Python 3: Use six types for strings
* Replace (str, unicode) with (six.binary_type, six.text_type) * Replace basestring with (six.binary_type, six.text_type)
Diffstat (limited to 'paste/httpexceptions.py')
-rw-r--r--paste/httpexceptions.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/paste/httpexceptions.py b/paste/httpexceptions.py
index d04308f..59d5b06 100644
--- a/paste/httpexceptions.py
+++ b/paste/httpexceptions.py
@@ -73,6 +73,7 @@ References:
"""
+import six
import types
from paste.wsgilib import catch_errors_app
from paste.response import has_header, header_value, replace_header
@@ -177,9 +178,9 @@ class HTTPException(Exception):
assert isinstance(headers, (type(None), list)), (
"headers must be None or a list: %r"
% headers)
- assert isinstance(detail, (type(None), basestring)), (
+ assert isinstance(detail, (type(None), six.binary_type, six.text_type)), (
"detail must be None or a string: %r" % detail)
- assert isinstance(comment, (type(None), basestring)), (
+ assert isinstance(comment, (type(None), six.binary_type, six.text_type)), (
"comment must be None or a string: %r" % comment)
self.headers = headers or tuple()
for req in self.required_headers:
@@ -206,7 +207,7 @@ class HTTPException(Exception):
for (k, v) in self.headers:
args[k.lower()] = escfunc(v)
for key, value in args.items():
- if isinstance(value, unicode):
+ if isinstance(value, six.text_type):
args[key] = value.encode('utf8', 'xmlcharrefreplace')
return template % args
@@ -236,7 +237,7 @@ class HTTPException(Exception):
else:
replace_header(headers, 'content-type', 'text/plain')
content = self.plain(environ)
- if isinstance(content, unicode):
+ if isinstance(content, six.text_type):
content = content.encode('utf8')
cur_content_type = (
header_value(headers, 'content-type')