diff options
author | Braedon Vickers <braedon.vickers@gmail.com> | 2020-04-17 19:42:23 +0800 |
---|---|---|
committer | Marcel Hellkamp <marc@gsites.de> | 2020-12-31 17:01:02 +0100 |
commit | f796498aaaaf2bc110efd494d4036d48999b1a61 (patch) | |
tree | 609c4635e928fbd4e97d3ec2b94158b631486c8e | |
parent | 2243ab241a4a3f05160d22dc42f054a824c426dd (diff) | |
download | bottle-f796498aaaaf2bc110efd494d4036d48999b1a61.tar.gz |
Don't re-raise critical errors that occur while handling an error
This logic was added to satisfy pep-3333, where the error handling section
says application authors should "never trap errors raised by start_response
when exc_info is being provided".
However, this appears to be intended to prevent applications from catching
exc_info being re-raised by start_response(), which happens when an
application tries to send an error response (includes exc_info), but can't
as output has already been written to the client. These exceptions should
be thrown up to the server so it can abort the connection, not caught by
the application.
In this case, the start_response() call in question may be an error
response, but it's always the first call to start_response(), so should
never re-raise exc_info in this way. As such, the special handling is
unnecessary.
-rwxr-xr-x | bottle.py | 3 |
1 files changed, 0 insertions, 3 deletions
@@ -1106,7 +1106,6 @@ class Bottle(object): def wsgi(self, environ, start_response): """ The bottle WSGI-interface. """ - provided_exc_info = False try: out = self._cast(self._handle(environ)) # rfc2616 section 4.3 @@ -1117,13 +1116,11 @@ class Bottle(object): exc_info = environ.get('bottle.exc_info') if exc_info is not None: del environ['bottle.exc_info'] - provided_exc_info = True start_response(response._wsgi_status_line(), response.headerlist, exc_info) return out except (KeyboardInterrupt, SystemExit, MemoryError): raise except Exception as E: - if provided_exc_info: raise if not self.catchall: raise err = '<h1>Critical error while processing request: %s</h1>' \ % html_escape(environ.get('PATH_INFO', '/')) |