[Twisted-Python] Sending unicode strings

Michal Chruszcz troll at pld-linux.org
Sat Apr 23 01:34:42 EDT 2005


I was undoubtedly surprised when I found out that I cannot pass unicode 
strings to Twisted.
In 1.3 twisted.internet.abstract looks like this:
    def write(self, data):
        assert isinstance(data, str), "Data must be a string."
        if not self.connected:

and in 2.0:
    def write(self, data):
        if isinstance(data, unicode): # no, really, I mean it
            raise TypeError("Data must be not be unicode")

Why do you mean it? Why I can't send unicode through twisted? It's 
ridiculous that I have to convert UTF8 strings to ISO on the client side 
and then once again from ISO to UTF8 on the server side, so I suppose 
you've got really good excuse.

Michal Chruszcz -=- Never seen

More information about the Twisted-Python mailing list