Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 19, 2019

Conversation

berkerpeksag
Copy link
Member

@berkerpeksag berkerpeksag commented Apr 22, 2019

Lib/wsgiref/handlers.py Outdated Show resolved Hide resolved
@berkerpeksag berkerpeksag requested a review from vadmium April 23, 2019 16:07
@vadmium
Copy link
Member

vadmium commented May 18, 2019

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
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
Contributor

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

@bedevere-bot
Copy link

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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.