Ticket #7993: destroy-the-supermoon.patch

File destroy-the-supermoon.patch, 2.8 KB (added by jMyles, 4 years ago)
  • twisted/web/test/test_wsgi.py

    diff --git twisted/web/test/test_wsgi.py twisted/web/test/test_wsgi.py
    index 4e902e5..ef939d5 100644
     
    44"""
    55Tests for L{twisted.web.wsgi}.
    66"""
     7import traceback
    78
    89__metaclass__ = type
    910
    class StartResponseTests(WSGITestsMixin, TestCase): 
    11871188                    'HTTP/1.1 200 OK\r\n'))
    11881189            self.assertEqual(reraised[0][0], excInfo[0])
    11891190            self.assertEqual(reraised[0][1], excInfo[1])
    1190             self.assertEqual(reraised[0][2].tb_next, excInfo[2])
     1191
     1192            # Show that the tracebacks end with the same stack frames.
     1193            tb1 = reraised[0][2].tb_next
     1194            tb2 = excInfo[2]
     1195            self.assertEqual(
     1196                traceback.extract_tb(tb1)[1],
     1197                traceback.extract_tb(tb2)[0]
     1198            )
     1199
    11911200
    11921201        d.addCallback(cbRendered)
    11931202
  • twisted/web/wsgi.py

    diff --git twisted/web/wsgi.py twisted/web/wsgi.py
    index 0918c4d..7d49af4 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])
     259            # raise excInfo[0]
    258260        self.status = status
    259261        self.headers = headers
    260262        return self.write
    class _WSGIResponse: 
    313315        """
    314316        try:
    315317            appIterator = self.application(self.environ, self.startResponse)
    316             for elem in appIterator:
     318            for elem in iterbytes(appIterator):
    317319                if elem:
    318320                    self.write(elem)
    319321                if self._requestFinished:
    class _WSGIResponse: 
    340342        self.started = True
    341343
    342344
    343 
     345@implementer(IResource)
    344346class WSGIResource:
    345347    """
    346348    An L{IResource} implementation which delegates responsibility for all
    class WSGIResource: 
    354356
    355357    @ivar _application: The WSGI application object.
    356358    """
    357     implements(IResource)
    358359
    359360    # Further resource segments are left up to the WSGI application object to
    360361    # handle.