diff --git a/paste/cgiapp.py b/paste/cgiapp.py index e5a62f45..bd45a5dd 100644 --- a/paste/cgiapp.py +++ b/paste/cgiapp.py @@ -253,7 +253,7 @@ def proc_communicate(proc, stdin=None, stdout=None, stderr=None): read_set.remove(proc.stderr) if trans_nl: data = proc._translate_newlines(data) - stderr.write(data) + stderr.write(six.ensure_text(data)) try: proc.wait() diff --git a/paste/errordocument.py b/paste/errordocument.py index 34f2d4a4..f7e28909 100644 --- a/paste/errordocument.py +++ b/paste/errordocument.py @@ -87,8 +87,6 @@ def keep_status_start_response(status, headers, exc_info=None): return self.app(environ, keep_status_start_response) except RecursionLoop as e: line = 'Recursion error getting error page: %s\n' % e - if six.PY3: - line = line.encode('utf8') environ['wsgi.errors'].write(line) keep_status_start_response('500 Server Error', [('Content-type', 'text/plain')], sys.exc_info()) body = ('Error: %s. (Error page could not be fetched)' diff --git a/paste/evalexception/middleware.py b/paste/evalexception/middleware.py index bc2883e4..6820e784 100644 --- a/paste/evalexception/middleware.py +++ b/paste/evalexception/middleware.py @@ -333,8 +333,6 @@ def detect_start_response(status, headers, exc_info=None): headers, exc_info) msg = 'Debug at: %s\n' % view_uri - if six.PY3: - msg = msg.encode('utf8') environ['wsgi.errors'].write(msg) exc_data = collector.collect_exception(*exc_info) diff --git a/paste/exceptions/errormiddleware.py b/paste/exceptions/errormiddleware.py index 95c1261c..9b533c55 100644 --- a/paste/exceptions/errormiddleware.py +++ b/paste/exceptions/errormiddleware.py @@ -221,7 +221,7 @@ def next(self): if self.closed: raise StopIteration try: - return self.app_iterator.next() + return next(self.app_iterator) except StopIteration: self.closed = True close_response = self._close() @@ -386,8 +386,6 @@ def handle_exception(exc_info, error_stream, html=True, else: line = ('Error - %s: %s\n' % (exc_data.exception_type, exc_data.exception_value)) - if six.PY3: - line = line.encode('utf8') error_stream.write(line) if html: if debug_mode and simple_html_error: diff --git a/paste/lint.py b/paste/lint.py index d7816864..7e5ac79a 100644 --- a/paste/lint.py +++ b/paste/lint.py @@ -217,7 +217,7 @@ def __init__(self, wsgi_errors): self.errors = wsgi_errors def write(self, s): - assert isinstance(s, bytes) + assert isinstance(s, six.string_types) self.errors.write(s) def flush(self): diff --git a/paste/wsgilib.py b/paste/wsgilib.py index ae472a07..65f27eba 100644 --- a/paste/wsgilib.py +++ b/paste/wsgilib.py @@ -291,7 +291,7 @@ def raw_interactive(application, path='', raise_on_wsgi_error=False, if raise_on_wsgi_error: errors = ErrorRaiser() else: - errors = six.BytesIO() + errors = six.StringIO() basic_environ = { # mandatory CGI variables 'REQUEST_METHOD': 'GET', # always mandatory @@ -604,4 +604,3 @@ def replacement(*args, **kw): if __name__ == '__main__': import doctest doctest.testmod() - diff --git a/tests/test_cgiapp.py b/tests/test_cgiapp.py index bfa04d5f..ea04b4cf 100644 --- a/tests/test_cgiapp.py +++ b/tests/test_cgiapp.py @@ -57,5 +57,4 @@ def test_stderr(): res = app.get('', expect_errors=True) assert res.status == 500 assert 'error' in res - assert b'some data' in res.errors - + assert 'some data' in res.errors