mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-29183: Fix double exceptions in wsgiref.handlers.BaseHandler (GH-12914)
This commit is contained in:
parent
f4e1babf44
commit
7c59362a15
3 changed files with 38 additions and 1 deletions
|
@ -183,7 +183,16 @@ class BaseHandler:
|
|||
for data in self.result:
|
||||
self.write(data)
|
||||
self.finish_content()
|
||||
finally:
|
||||
except:
|
||||
# Call close() on the iterable returned by the WSGI application
|
||||
# in case of an exception.
|
||||
if hasattr(self.result, 'close'):
|
||||
self.result.close()
|
||||
raise
|
||||
else:
|
||||
# We only call close() when no exception is raised, because it
|
||||
# will set status, result, headers, and environ fields to None.
|
||||
# See bpo-29183 for more details.
|
||||
self.close()
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue