On Fri, May 1, 2009 at 4:54 PM, Pablo P. F. de Faria
<[email protected]> wrote:
> Hi, Kent.
>
> The stack trace is:
>
> Traceback (most recent call last):
> File "/home/pablo/workspace/E-Dictor/src/MainFrame.py", line 1057, in OnClose
> self.SavePreferences()
> File "/home/pablo/workspace/E-Dictor/src/MainFrame.py", line 1068,
> in SavePreferences
> self.cfg.set(u'File Settings',u'Recent files',
> unicode(",".join(self.recent_files)))
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
> 12: ordinal not in range(128)
>
> The "unicode" function, actually doesn't do any difference... The
> content of the string being saved is "/home/pablo/Área de
> Trabalho/teste.xml".
OK, this error is in your code, not the ConfigParser. The problem is with
",".join(self.recent_files)
Are the entries in self.recent_files unicode strings? If so, then I
think the join is trying to convert to a string using the default
codec. Try
self.cfg.set('File Settings','Recent files',
','.join(name.encode('utf-8') for name in self.recent_files))
Looking at the ConfigParser.write() code, it wants the values to be
strings or convertible to strings by calling str(), so non-ascii
unicode values will be a problem there. I would use plain strings for
all the interaction with ConfigParser and convert to Unicode yourself.
Kent
PS Please Reply All to reply to the list.
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor