[Twisted-Python] A bug of the DNSDatagramProtocol
when i run the code: df = Deferred() name = Name('version.bind') axf = AXFRController(name,df) dns = DNSDatagramProtocol(axf) d = dns.query((ip,53),[Query('version.bind',TXT,CH)]) it raise the error : Traceback (most recent call last): File "/usr/local/lib/python2.7/site-packages/twisted/python/log.py", line 73, in callWithContext return context.call({ILogContext: newCtx}, func, *args, **kw) File "/usr/local/lib/python2.7/site-packages/twisted/python/context.py", line 118, in callWithContext return self.currentContext().callWithContext(ctx, func, *args, **kw) File "/usr/local/lib/python2.7/site-packages/twisted/python/context.py", line 81, in callWithContext return func(*args,**kw) File "/usr/local/lib/python2.7/site-packages/twisted/internet/posixbase.py", line 614, in _doReadOrWrite why = selectable.doRead() --- <exception caught here> --- File "/usr/local/lib/python2.7/site-packages/twisted/internet/udp.py", line 149, in doRead self.protocol.datagramReceived(data, addr) File "/usr/local/lib/python2.7/site-packages/twisted/names/dns.py", line 1936, in datagramReceived self.controller.messageReceived(m, self, addr) exceptions.TypeError: messageReceived() takes exactly 3 arguments (4 given) Unhandled Error and the I set the DNSDatagramProtocol.datagramReceived's last row self.controller.messageReceived(m, self, addr) to self.controller.messageReceived(m, self) it'ok! And this is a bug????
On 03:24 am, z858570636@gmail.com wrote:
when i run the code: df = Deferred() name = Name('version.bind') axf = AXFRController(name,df) dns = DNSDatagramProtocol(axf) d = dns.query((ip,53),[Query('version.bind',TXT,CH)]) it raise the error : Traceback (most recent call last): File "/usr/local/lib/python2.7/site-packages/twisted/python/log.py", line 73, in callWithContext return context.call({ILogContext: newCtx}, func, *args, **kw) File "/usr/local/lib/python2.7/site- packages/twisted/python/context.py", line 118, in callWithContext return self.currentContext().callWithContext(ctx, func, *args, **kw) File "/usr/local/lib/python2.7/site- packages/twisted/python/context.py", line 81, in callWithContext return func(*args,**kw) File "/usr/local/lib/python2.7/site-packages/twisted/internet/posixbase.py", line 614, in _doReadOrWrite why = selectable.doRead() --- <exception caught here> --- File "/usr/local/lib/python2.7/site-packages/twisted/internet/udp.py", line 149, in doRead self.protocol.datagramReceived(data, addr) File "/usr/local/lib/python2.7/site-packages/twisted/names/dns.py", line 1936, in datagramReceived self.controller.messageReceived(m, self, addr) exceptions.TypeError: messageReceived() takes exactly 3 arguments (4 given) Unhandled Error
and the I set the DNSDatagramProtocol.datagramReceived's last row self.controller.messageReceived(m, self, addr) to self.controller.messageReceived(m, self) it'ok! And this is a bug????
Hello,
I tried turning your code into an http://sscce.org/:
from __future__ import print_function
from twisted.internet.defer import Deferred
from twisted.names.dns import TXT, CH, Name, Query,
DNSDatagramProtocol
from twisted.names.client import AXFRController
from twisted.internet.task import react
def main(reactor):
ip = '8.8.8.8'
df = Deferred()
name = Name('version.bind')
axf = AXFRController(name,df)
dns = DNSDatagramProtocol(axf)
d = dns.query((ip,53),[Query('version.bind',TXT,CH)])
d.addCallback(print)
return d
react(main, [])
But I wasn't able to reproduce the error you encountered, instead I get
the output:
participants (2)
-
exarkun@twistedmatrix.com
-
yuyan zhang