[Chicago] =?gb2312?q?re=A3=BA=20Re:=20=20UnicodeDecodeError=20When=20compi?= =?gb2312?q?ling=20BitTorrent=20in=20BitTornado?=
=?gb2312?q?=B7=C5=DC=F8=20=CC=B8?=
jolley84 at yahoo.com.cn
Mon Oct 9 07:45:05 CEST 2006
first, as a newbie, i may ask some foolish problems, pls be patient and endurable.
second, i have done this after your explanation:
from sys import getfilesystemencoding
path.decode(sys.getfilesystemencoding)
path = ("\\").decode(sys.getfilesystemencoding()) +b.decode(sys.getfilesystemencoding())
and in this way i translate all the objects involved to be a way of file system encoding on purpose of avoiding unicodeDecodeError,but the bug remains.am i doing right? thanks,
as for the first two bugs,
savedas = dow.saveAs(choosefile,d.newpath)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 33-34: ordinal not in range(128)
here choosefile,and d.newpath are the functions, if concerning encodings/decodings, i donot know how to put it to right. coz choosefile and d.newpath both are functions,neither buffers nor strings, IMO,the only doing will be performed on dow.saveAs(choosefile,d.newpath).decode/encode('utf-8').however the feedback is the same bug.
and the second:
for x in self.info['files']:
if path.exists(path.join(file, x['path'][0])):
existing = 1
UnicodeEncodeError: 'ascii' codec can't encode characters in position 33-34: ordinal not in range(128),and i have no idea about that.
thanks
jolley
Ian Bicking <ianb at colorstudy.com> дµÀ£º
> 12. File "C:\Python24\lib\ntpath.py", line 102, in join
> 13. path += "\\" + b
> 14. UnicodeDecodeError: 'ascii' codec can't decode byte 0xb9 in position 1: ordinal not in range(128)
This evaluates path + ("\\"+b)
That means that if b is unicode, ("\\"+b) will be a unicode string. No
exception occurs, because "\\".decode('ascii') works fine.
Then when you add that to path, if path is not unicode then
path.decode('ascii') is called. This is the exception you are getting.
So at some point a file or configuration value or something like that is
reading an encoded and non-ASCII string, and using that as "path". Then
the unicode object "b" is being appended to that. Or the other way
around might be true -- path is unicode and b is a non-ASCII encoded string.
I'm not really sure what the code should be, though I suppose ideally
sys.getfilesystemencoding() would be used to decode those strings
instead of ASCII. This stuff can be a real mess.
--
Ian Bicking | ianb at colorstudy.com | http://blog.ianbicking.org
_______________________________________________
Chicago mailing list
Chicago at python.org
http://mail.python.org/mailman/listinfo/chicago
---------------------------------
ÇÀ×¢ÑÅ»¢Ãâ·ÑÓÊÏä-3.5GÈÝÁ¿£¬20M¸½¼þ£¡
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/chicago/attachments/20061009/25da88ad/attachment.htm
More information about the Chicago
mailing list