← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~james-w/python-oops-wsgi/start_response-exc_info into lp:python-oops-wsgi

 

James Westby has proposed merging lp:~james-w/python-oops-wsgi/start_response-exc_info into lp:python-oops-wsgi.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #903573 in python-oops-wsgi: "TypeError: start_response() takes no keyword arguments"
  https://bugs.launchpad.net/python-oops-wsgi/+bug/903573

For more details, see:
https://code.launchpad.net/~james-w/python-oops-wsgi/start_response-exc_info/+merge/90031

Hi,

As discussed exc_info shouldn't be passed as a keyword argument.

Thanks,

James
-- 
https://code.launchpad.net/~james-w/python-oops-wsgi/start_response-exc_info/+merge/90031
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~james-w/python-oops-wsgi/start_response-exc_info into lp:python-oops-wsgi.
=== modified file 'oops_wsgi/middleware.py'
--- oops_wsgi/middleware.py	2011-12-09 04:06:45 +0000
+++ oops_wsgi/middleware.py	2012-01-25 02:32:24 +0000
@@ -193,7 +193,7 @@
                 headers = [('Content-Type', content_type)]
                 headers.append(('X-Oops-Id', str(report['id'])))
                 start_response(
-                    '500 Internal Server Error', headers, exc_info=exc_info)
+                    '500 Internal Server Error', headers, exc_info)
                 del exc_info
                 if error_render is not None:
                     return error_render(report)

=== modified file 'oops_wsgi/tests/test_middleware.py'
--- oops_wsgi/tests/test_middleware.py	2011-12-09 04:06:45 +0000
+++ oops_wsgi/tests/test_middleware.py	2012-01-25 02:32:24 +0000
@@ -544,6 +544,25 @@
             Equals(expected_start_response),
             ]))
 
+    def test_calls_start_response_with_postition_exc_info(self):
+        def myapp(environ, start_response):
+            raise ValueError('boom, yo')
+        config = self.config_for_oopsing(capture_create=True)
+        app = make_app(myapp, config)
+        environ = self.make_outer_environ()
+        def start_response(*args, **kwargs):
+            if kwargs:
+                raise AssertionError(
+                    "start_response takes no kwargs: %s" % str(kwargs))
+            return self.calls.append
+        iterator = iter(app(environ, start_response))
+        # get one item from it, which is enough to ensure we've activated
+        # all the frames.
+        step = iterator.next()
+        # the client pipe is closed or something - we discard the iterator
+        del iterator
+        gc.collect()
+        return step
 
 
 class TestGeneratorTracker(TestCase):