On 4/29/2013 5:47 AM, c...@isbd.net wrote:

case).  Here's the traceback:-


   File "/usr/local/lib/python2.7/dist-packages/gallery/picture.py", line 361,
> in createPictureHTML file.write("".join(html).encode('utf-8'))
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 783: ordinal not in range(128)

Generiric advice for anyone getting unicode errors:
unpack the composition producing the error
so that one can see which operation produced it.

In this case
s = "".join(html)\
s = s.encode('utf-8')
file.write(s)

This also makes it possible to print intermediate results.
  print(type(s), s)  # would have been useful
Doing so would have immediately shown that in this case the error was the encode operation, because s was already bytes. For many other posts, the error with the same type of message has been the print or write operation, do to output encoding issues, but that was not the case here.




--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to