Ticket #7993: destroy-the-supermoon2.patch

File destroy-the-supermoon2.patch, 5.0 KB (added by jMyles, 4 years ago)
  • twisted/python/dist3.py

    diff --git twisted/python/dist3.py twisted/python/dist3.py
    index 5735377..a5198ae 100644
    modules = [ 
    219219    "twisted.web.test.requesthelper",
    220220    "twisted.web.util",
    221221    "twisted.web.xmlrpc",
     222    "twisted.web.wsgi"
    222223]
    223224
    224225
    testModules = [ 
    381382    "twisted.web.test.test_web__responses",
    382383    "twisted.web.test.test_webclient",
    383384    "twisted.web.test.test_xmlrpc",
     385    "twisted.web.test.test_wsgi",
    384386]
    385387
    386388
  • twisted/web/test/test_wsgi.py

    diff --git twisted/web/test/test_wsgi.py twisted/web/test/test_wsgi.py
    index 4e902e5..df86898 100644
     
    44"""
    55Tests for L{twisted.web.wsgi}.
    66"""
     7import traceback
    78
    89__metaclass__ = type
    910
    class EnvironTests(WSGITestsMixin, TestCase): 
    209210    object by L{twisted.web.wsgi.WSGIResource}.
    210211    """
    211212    def environKeyEqual(self, key, value):
    212         def assertEnvironKeyEqual((environ, startResponse)):
     213        def assertEnvironKeyEqual(wsgi_params):
     214            environ, startResponse = wsgi_params
    213215            self.assertEqual(environ[key], value)
    214216        return assertEnvironKeyEqual
    215217
    class EnvironTests(WSGITestsMixin, TestCase): 
    220222        parameter which is exactly of type C{dict}.
    221223        """
    222224        d = self.render('GET', '1.1', [], [''])
    223         def cbRendered((environ, startResponse)):
     225        def cbRendered(wsgi_params):
     226            environ, startResponse = wsgi_params
    224227            self.assertIdentical(type(environ), dict)
    225228        d.addCallback(cbRendered)
    226229        return d
    class EnvironTests(WSGITestsMixin, TestCase): 
    444447        """
    445448        singleValue = self.render(
    446449            'GET', '1.1', [], [''], None, [('foo', 'bar'), ('baz', 'quux')])
    447         def cbRendered((environ, startResponse)):
     450        def cbRendered(wsgi_params):
     451            environ, startResponse = wsgi_params
    448452            self.assertEqual(environ['HTTP_FOO'], 'bar')
    449453            self.assertEqual(environ['HTTP_BAZ'], 'quux')
    450454        singleValue.addCallback(cbRendered)
    class EnvironTests(WSGITestsMixin, TestCase): 
    541545        self.addCleanup(removeObserver, events.append)
    542546
    543547        errors = self.render('GET', '1.1', [], [''])
    544         def cbErrors((environ, startApplication)):
     548        def cbErrors(wsgi_params):
     549            environ, startResponse = wsgi_params
    545550            errors = environ['wsgi.errors']
    546551            errors.write('some message\n')
    547552            errors.writelines(['another\nmessage\n'])
    class StartResponseTests(WSGITestsMixin, TestCase): 
    11871192                    'HTTP/1.1 200 OK\r\n'))
    11881193            self.assertEqual(reraised[0][0], excInfo[0])
    11891194            self.assertEqual(reraised[0][1], excInfo[1])
    1190             self.assertEqual(reraised[0][2].tb_next, excInfo[2])
     1195
     1196            # Show that the tracebacks end with the same stack frames.
     1197            tb1 = reraised[0][2].tb_next
     1198            tb2 = excInfo[2]
     1199            self.assertEqual(
     1200                traceback.extract_tb(tb1)[1],
     1201                traceback.extract_tb(tb2)[0]
     1202            )
     1203
    11911204
    11921205        d.addCallback(cbRendered)
    11931206
  • twisted/web/wsgi.py

    diff --git twisted/web/wsgi.py twisted/web/wsgi.py
    index 0918c4d..7a22f9a 100644
     
    55An implementation of
    66U{Web Resource Gateway Interface<http://www.python.org/dev/peps/pep-0333/>}.
    77"""
     8from twisted.python.compat import iterbytes, reraise
    89
    910__metaclass__ = type
    1011
    1112from sys import exc_info
    1213
    13 from zope.interface import implements
     14from zope.interface import implementer
    1415
    1516from twisted.python.log import msg, err
    1617from twisted.python.failure import Failure
    class _WSGIResponse: 
    183184        else:
    184185            pathInfo = ''
    185186
    186         parts = request.uri.split('?', 1)
     187        parts = request.uri.split(b'?', 1)
    187188        if len(parts) == 1:
    188189            queryString = ''
    189190        else:
    class _WSGIResponse: 
    254255        This will be called in a non-I/O thread.
    255256        """
    256257        if self.started and excInfo is not None:
    257             raise excInfo[0], excInfo[1], excInfo[2]
     258            reraise(excInfo[1], excInfo[2])
    258259        self.status = status
    259260        self.headers = headers
    260261        return self.write
    class _WSGIResponse: 
    313314        """
    314315        try:
    315316            appIterator = self.application(self.environ, self.startResponse)
    316             for elem in appIterator:
     317            for elem in iterbytes(appIterator):
    317318                if elem:
    318319                    self.write(elem)
    319320                if self._requestFinished:
    class _WSGIResponse: 
    340341        self.started = True
    341342
    342343
    343 
     344@implementer(IResource)
    344345class WSGIResource:
    345346    """
    346347    An L{IResource} implementation which delegates responsibility for all
    class WSGIResource: 
    354355
    355356    @ivar _application: The WSGI application object.
    356357    """
    357     implements(IResource)
    358358
    359359    # Further resource segments are left up to the WSGI application object to
    360360    # handle.