On Nov 5, 2019, at 12:20 PM, Nathaniel Haggard <natester@gmail.com> wrote:

# This code doesn't call getChild in python3, but it does in python2 (python2 throws AttributeError, but python3 doesn't) with "curl http://127.0.0.1:8803/bug/a" and Twisted==19.7.0 with python3.5.2:

from twisted.application import internet, service, strports
from twisted.web.resource import Resource
from twisted.web.server import Site
from twisted.internet import reactor
from twisted.python import log


from twisted.web.resource import Resource



class R(Resource):
    allowedMethods=('GET',)
    def getChild(self, name, request):
        pass
       

r = Resource()
r.putChild('bug', R())

This isn't technically a bug in Twisted, since you're passing a `str` on py3 where it expects a `bytes`; note the "type" annotation right at the end of https://twistedmatrix.com/documents/19.7.0/api/twisted.web.resource.IResource.html#putChild .

In other words, you meant `r.putChild(b'bug', R())`.

That said, this is certainly not desirable behavior, so maybe we could fix it?  There are probably a couple of gnarly compatibility concerns to think about, but it would be nice if it worked.

-g

application = service.Application('web')
site = Site(r)
sc = service.IServiceCollection(application)
i = strports.service("tcp:8803", site)
i.setServiceParent(sc)

_______________________________________________
Twisted-web mailing list
Twisted-web@twistedmatrix.com
https://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web