On Wed, May 5, 2010 at 4:29 PM, Pet <petshm...@googlemail.com> wrote: > On Wed, May 5, 2010 at 4:15 PM, Pet <petshm...@googlemail.com> wrote: >> On Wed, May 5, 2010 at 2:49 PM, Itamar Turner-Trauring >> <ita...@itamarst.org> wrote: >>> On Wed, 2010-05-05 at 13:45 +0200, Pet wrote: >>>> Hello! >>>> >>>> I'm using Twisted 10.0 and as usually sometime print debug infos with >>>> myunicodestr.encode('UTF-8') which are saved to logfile, but since >>>> using twisted 10 I'm getting >>>> >>>> UnicodeEncodeError: 'ascii' codec can't encode characters... >>>> >>>> type(myunicodestr) returns <type 'unicode'> >>>> >>>> >>>> What is the problem here? >>> >>> This works fine for me (Twisted trunk): >>> >>> $ python2.5 -c "import sys; from twisted.python import log; \ >>> log.startLogging(file('/tmp/log', 'w')); print \ >>> u'\u1234'.encode('UTF-8')" >>> $ cat /tmp/log >>> 2010-05-05 08:48:40-0400 [-] Log opened. >>> 2010-05-05 08:48:40-0400 [-] ሴ >>> >>> Can you include a minimal reproducing example? >> >> If I print as you do it works, but my string is fetched from database >> and only then it fails > > It's pretty weird. I've send as parameter {'s': u'c\u0142a'} to > twisted xml-rpc server after it was restarted and it has printed > param['s'].encode('UTF-8') without errors. Immidiately after that I've > send the same request again and it failed to print it. I've restarted > the server again and at the first request it prints without errors, > all other requests raise exceptions. So it has nothing to do with > database.
Now, I'm getting Exception with File "/usr/local/tw10/lib/python2.5/site-packages/Twisted-10.0.0-py2.5-linux-x86_64.egg/twisted/python/log.py", line 555, in write d = (self.buf + data).split('\n') exceptions.UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 4: ordinal not in range(128) > >> >>> >>> >>> _______________________________________________ >>> Twisted-Python mailing list >>> Twisted-Python@twistedmatrix.com >>> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python >>> >> > _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python