On Wed, 30 Jan 2013 11:04:36 -0800 Glyph <gl...@twistedmatrix.com> wrote:
> Any volunteers for parts of this process? I'm not familiar with Twisted patching process and for this reason I'm just attaching a small patch here for #6245 because I'd like to discuss about the approach. If correct I will move on in the process (hopefully in the right way) The patch simply tries to encode the name argument properly if unicode. This is the same approach used by ralphm but applied to Name class initialization so it should be really generic. Just about a doubt about how to handle an exception potentially raised during the name encoding. Any idea? Ciao. PS Attached a simple test code which forces the name to resolve to be unicode. It fails against 12.3.0 while it is correclty executed after patching. -- Angelo Dell'Aera 'buffer' Antifork Research, Inc. http://buffer.antifork.org Sysenter Honeynet Project http://www.sysenter-honeynet.org
#!/usr/bin/env python # Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ Returns the IP address for a given hostname. To run this script: $ python gethostbyname.py <hostname> e.g.: $ python gethostbyname.py www.google.com """ import sys from twisted.names import client from twisted.internet import reactor def gotResult(result): print result reactor.stop() def gotFailure(failure): failure.printTraceback() reactor.stop() d = client.getHostByName(unicode(sys.argv[1])) d.addCallbacks(gotResult, gotFailure) reactor.run()
--- dns.py.old 2013-01-30 23:13:20.000000000 +0100 +++ dns.py 2013-01-30 23:21:53.000000000 +0100 @@ -353,6 +353,13 @@ @type name: C{bytes} """ def __init__(self, name=b''): + if isinstance(name, unicode): + warnings.warn( + "Domain argument to twisted.names.dns.Name" + "should be bytes, not unicode, since Twisted 12.3.0", + category=DeprecationWarning, + stacklevel=2) + name = name.encode('ascii') if not isinstance(name, bytes): raise TypeError("%r is not a byte string" % (name,)) self.name = name
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python