diff options
author | Dave Brondsema <dave@brondsema.net> | 2020-10-12 08:25:18 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-12 13:25:18 +0100 |
commit | 652112c1d99a47809ef0dd8ba9992179262fb3d8 (patch) | |
tree | 3448afd8a874375f3f00dc7a34591d7e5cfa6f09 | |
parent | 0370a8368fb5e2019dce4261c8a113f6cd41347e (diff) | |
download | paste-git-652112c1d99a47809ef0dd8ba9992179262fb3d8.tar.gz |
Wsgi.errors is text (#62)
* Update next() to work with py3
* wsgi.errors is supposed to be text, fixes ErrorMiddleware on py3
-rw-r--r-- | paste/cgiapp.py | 2 | ||||
-rw-r--r-- | paste/errordocument.py | 2 | ||||
-rw-r--r-- | paste/evalexception/middleware.py | 2 | ||||
-rw-r--r-- | paste/exceptions/errormiddleware.py | 4 | ||||
-rw-r--r-- | paste/lint.py | 2 | ||||
-rw-r--r-- | paste/wsgilib.py | 3 | ||||
-rw-r--r-- | tests/test_cgiapp.py | 3 |
7 files changed, 5 insertions, 13 deletions
diff --git a/paste/cgiapp.py b/paste/cgiapp.py index e5a62f4..bd45a5d 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 34f2d4a..f7e2890 100644 --- a/paste/errordocument.py +++ b/paste/errordocument.py @@ -87,8 +87,6 @@ class StatusKeeper(object): 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 bc2883e..6820e78 100644 --- a/paste/evalexception/middleware.py +++ b/paste/evalexception/middleware.py @@ -333,8 +333,6 @@ class EvalException(object): 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 95c1261..9b533c5 100644 --- a/paste/exceptions/errormiddleware.py +++ b/paste/exceptions/errormiddleware.py @@ -221,7 +221,7 @@ class CatchingIter(object): 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 d781686..7e5ac79 100644 --- a/paste/lint.py +++ b/paste/lint.py @@ -217,7 +217,7 @@ class ErrorWrapper(object): 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 ae472a0..65f27eb 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 @@ for _name in __all__: if __name__ == '__main__': import doctest doctest.testmod() - diff --git a/tests/test_cgiapp.py b/tests/test_cgiapp.py index bfa04d5..ea04b4c 100644 --- a/tests/test_cgiapp.py +++ b/tests/test_cgiapp.py @@ -57,5 +57,4 @@ if sys.platform != 'win32' and not sys.platform.startswith('java'): 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 |