On Wed, May 5, 2010 at 4:15 PM, Pet <[email protected]> wrote:
> On Wed, May 5, 2010 at 2:49 PM, Itamar Turner-Trauring
> <[email protected]> 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.
>
>>
>>
>> _______________________________________________
>> Twisted-Python mailing list
>> [email protected]
>> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>>
>
_______________________________________________
Twisted-Python mailing list
[email protected]
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python