Skip to content

bpo-29183: Fix double exceptions in wsgiref.handlers.BaseHandler#12914

Merged
berkerpeksag merged 1 commit into
python:masterfrom
berkerpeksag:bpo-29183-wsgiref
May 19, 2019
Merged

bpo-29183: Fix double exceptions in wsgiref.handlers.BaseHandler#12914
berkerpeksag merged 1 commit into
python:masterfrom
berkerpeksag:bpo-29183-wsgiref

Conversation

@berkerpeksag

@berkerpeksag berkerpeksag commented Apr 22, 2019

Copy link
Copy Markdown
Member

Comment thread Lib/wsgiref/handlers.py Outdated
@berkerpeksag
berkerpeksag requested a review from vadmium April 23, 2019 16:07
@vadmium

vadmium commented May 18, 2019

Copy link
Copy Markdown
Member

Revision da0ca97 looks okay to me. I presume without the fix, the test would fail because the h.run call will raise the double exception.

@berkerpeksag

Copy link
Copy Markdown
Member Author

@vadmium thanks for the review! Yes, the test will fail without the fix:

======================================================================
ERROR: testDontResetInternalStateOnException (test.test_wsgiref.HandlerTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/berkerpeksag/projects/cpython/Lib/wsgiref/handlers.py", line 138, in run
    self.finish_response()
  File "/Users/berkerpeksag/projects/cpython/Lib/wsgiref/handlers.py", line 184, in finish_response
    self.write(data)
  File "/Users/berkerpeksag/projects/cpython/Lib/wsgiref/handlers.py", line 289, in write
    self.send_headers()
  File "/Users/berkerpeksag/projects/cpython/Lib/wsgiref/handlers.py", line 347, in send_headers
    self.send_preamble()
  File "/Users/berkerpeksag/projects/cpython/Lib/wsgiref/handlers.py", line 267, in send_preamble
    self._write(('HTTP/%s %s\r\n' % (self.http_version,self.status)).encode('iso-8859-1'))
  File "/Users/berkerpeksag/projects/cpython/Lib/wsgiref/handlers.py", line 468, in _write
    result = self.stdout.write(data)
  File "/Users/berkerpeksag/projects/cpython/Lib/test/test_wsgiref.py", line 819, in write
    raise CustomException
test.test_wsgiref.HandlerTests.testDontResetInternalStateOnException.<locals>.CustomException

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/berkerpeksag/projects/cpython/Lib/test/test_wsgiref.py", line 824, in testDontResetInternalStateOnException
    h.run(hello_app)
  File "/Users/berkerpeksag/projects/cpython/Lib/wsgiref/handlers.py", line 145, in run
    self.handle_error()
  File "/Users/berkerpeksag/projects/cpython/Lib/wsgiref/handlers.py", line 383, in handle_error
    self.finish_response()
  File "/Users/berkerpeksag/projects/cpython/Lib/wsgiref/handlers.py", line 184, in finish_response
    self.write(data)
  File "/Users/berkerpeksag/projects/cpython/Lib/wsgiref/handlers.py", line 289, in write
    self.send_headers()
  File "/Users/berkerpeksag/projects/cpython/Lib/wsgiref/handlers.py", line 346, in send_headers
    if not self.origin_server or self.client_is_modern():
  File "/Users/berkerpeksag/projects/cpython/Lib/wsgiref/handlers.py", line 359, in client_is_modern
    return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'
TypeError: 'NoneType' object is not subscriptable

----------------------------------------------------------------------

@berkerpeksag
berkerpeksag merged commit 7c59362 into python:master May 19, 2019
@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @berkerpeksag for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒⛏🤖

@bedevere-bot

Copy link
Copy Markdown

GH-13424 is a backport of this pull request to the 3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 19, 2019
…honGH-12914)

(cherry picked from commit 7c59362)

Co-authored-by: Berker Peksag <berker.peksag@gmail.com>
berkerpeksag added a commit that referenced this pull request May 19, 2019
…12914)

(cherry picked from commit 7c59362)

Co-authored-by: Berker Peksag <berker.peksag@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants