[Twisted-Python] Twisted Names strings

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Thu Jan 17 12:19:01 EST 2013

On 04:22 pm, angelo.dellaera at gmail.com wrote:
>After updating Twisted to 12.3.0 I started getting errors like the 
>following one
>2013-01-17 14:38:23+0100 [-]   File "/usr/lib64/python2.7/site- 
>packages/twisted/names/common.py", line 93, in lookupAddress
>2013-01-17 14:38:23+0100 [-]     return self._lookup(name, dns.IN, 
>dns.A, timeout)
>2013-01-17 14:38:23+0100 [-]   File "/usr/lib64/python2.7/site- 
>packages/twisted/names/client.py", line 384, in _lookup
>2013-01-17 14:38:23+0100 [-]     d = self.queryUDP([dns.Query(name, 
>type, cls)], timeout)
>2013-01-17 14:38:23+0100 [-]   File "/usr/lib64/python2.7/site- 
>packages/twisted/names/dns.py", line 484, in __init__
>2013-01-17 14:38:23+0100 [-]     self.name = Name(name)
>2013-01-17 14:38:23+0100 [-]   File"/usr/lib64/python2.7/site- 
>packages/twisted/names/dns.py", line 357, in __init__
>2013-01-17 14:38:23+0100 [-]     raise TypeError("%r is not a byte 
>string" % (name,))
>2013-01-17 14:38:23+0100 [-] TypeError: u'example.com' is not a byte 
>Taking a look at documentation I found this document
>which states
>"twisted.names.dns deals with strings with a wide range of meanings,
>often several for each DNS record type. Most of these strings have
>remained as byte strings, which will probably require application
>updates (for the reason given in the FilePath section above). Some
>strings have changed to text strings, though. Any string representing a
>human readable address (for example, Record_A's address parameter) is
>now a text string. Additionally, time-to-live (ttl) values given as
>strings must now be given as text strings."
>which seems to describe the problem I'm experiencing.
>But let me say that I'm currently using Python 2.7.3 and I was 
>surprised in realizing
>that a simple update from a minor 12.x release was enough to disrupt my 
>Don't you think that a kind of compatibility mechanism (maybe with a 
>warning message)
>would have been a more gentle way of doing this transition especially 
>for those who
>are still using Python 2?

Absolutely.  This issue has been reported in connection to Wokkel 


There is currently a fix proposed and waiting review, and there has been 
some discussion about doing a maintenance release of 12.3 to distribute 
the fix.  Thank you for reporting your experience with 12.3.0 (although 
testing during the /pre/-release period would have saved everyone some 
trouble :).

It would be great if you could try out the proposed fix and let us know 
if it also addresses the problem with your application.

Since some concern has been voiced over the effort necessary to do a 
12.3.1 release (as opposed to just including this fix in 13.0), I'd also 
be interested to know whether one or the other of those would be more 
helpful for you - does anything prevent you (or your users) from 
upgrading to 13.0 once it is released?


More information about the Twisted-Python mailing list