From 4262b41da195cb959abf4a5a06ce34a6dec2c4a3 Mon Sep 17 00:00:00 2001 From: Cyril Roelandt Date: Tue, 18 Mar 2014 12:47:02 +0100 Subject: 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) --- paste/httpexceptions.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'paste/httpexceptions.py') 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') -- cgit v1.2.1