Re: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe1 in position 7: ordinal not in range(128)

On Fri, 2006-04-21 at 11:11 -0400, Elias Torres wrote:
> I have user from Argentina using my service (http://torrez.us/ics2rdf)
> based on the toIcal.py scripts. However, he has non-ascii characters and
> the script is failing. I just wanted to report the bug.

I'm not able to reproduce a failing of the script. The diagnostic
I get suggests the data is bad:

UnicodeDecodeError: 'utf8' codec can't decode bytes in position 0-2:
invalid data

What version of fromIcal.py are you using?

I'm using:
$Id: fromIcal.py,v 2.31 2006/04/11 20:29:00 connolly Exp $

I'm attaching a CVS log with dates so you can perhaps see which
version you grabbed.

(I'd rather use a public version control history... but...
sigh... long story...)

connolly@dirk:~/Desktop$ python2.4 -i
~/w3ccvs/WWW/2002/12/cal/fromIcal.py basic.ics
Traceback (most recent call last):
  File "/home/connolly/w3ccvs/WWW/2002/12/cal/fromIcal.py", line 825,
in ?
    main()
  File "/home/connolly/w3ccvs/WWW/2002/12/cal/fromIcal.py", line 99, in
main
    interpret(sx, codecs.open(sys.argv[1], 'r', 'utf-8'), base,
suppressed)
  File "/home/connolly/w3ccvs/WWW/2002/12/cal/fromIcal.py", line 135, in
interpret
    findComponents(lines, v, calendars)
  File "/home/connolly/w3ccvs/WWW/2002/12/cal/fromIcal.py", line 801, in
findComponents
    findComponents(lines, v, subs)
  File "/home/connolly/w3ccvs/WWW/2002/12/cal/fromIcal.py", line 784, in
findComponents
    n, p, v = parseLine(lines.next(), downcase=False)
  File "/home/connolly/w3ccvs/WWW/2002/12/cal/icslex.py", line 165, in
unbreak
    s = lines.next().rstrip(CRLF)
  File "/usr/lib/python2.4/codecs.py", line 494, in next
    return self.reader.next()
  File "/usr/lib/python2.4/codecs.py", line 431, in next
    line = self.readline()
  File "/usr/lib/python2.4/codecs.py", line 346, in readline
    data = self.read(readsize, firstline=True)
  File "/usr/lib/python2.4/codecs.py", line 293, in read
    newchars, decodedbytes = self.decode(data, self.errors)
UnicodeDecodeError: 'utf8' codec can't decode bytes in position 0-2:
invalid data



> 
> -Elias
> 
>   File "index.py", line 24, in ?
>     main()
>   File "index.py", line 15, in main
>     fromIcal.interpret(sx, ical, url, ['X-'])
>   File "/_ics2rdf/fromIcal.py", line 142, in interpret
>     doComponents(sx, calendars, iCalendarDefs, suppressed = suppressed)
>   File "/_ics2rdf/fromIcal.py", line 350, in doComponents
>     doComponents(sx, subs, subDecls, 'component', suppressed = suppressed)
>   File "/_ics2rdf/fromIcal.py", line 345, in doComponents
>     doProperties(sx, '', props, propDecls, suppressed = suppressed)
>   File "/_ics2rdf/fromIcal.py", line 467, in doProperties
>     doCalAddress(sx, elt, params, val)
>   File "/_ics2rdf/fromIcal.py", line 662, in doCalAddress
>     sx.characters(pv, 0, len(pv))
>   File "/_ics2rdf/XMLWriter.py", line 79, in characters
>     doChars(o, ch, start, length)
>   File "/_ics2rdf/XMLWriter.py", line 92, in doChars
>     o.write(ch[i:])
>   File "/usr/lib/python2.4/codecs.py", line 178, in write
>     data, consumed = self.encode(object, self.errors)

-- 
Dan Connolly, W3C http://www.w3.org/People/Connolly/
D3C2 887B 0F92 6005 C541  0875 0F91 96DE 6E52 C29E

Received on Friday, 21 April 2006 15:47:50 UTC