anatoly techtonik
2012-12-24 01:29:43 UTC
The following code fails with UnicodeDecode error and I am completely
puzzled about what does it want.
import genshi
iURL = "http://bugs.farmanager.com/view.php?id=1736"
import urllib2
mbt_file = urllib2.urlopen(iURL)
mbt_genshi = genshi.input.HTMLParser(mbt_file)
parsed = mbt_genshi.parse()
parsed.select("head").render()
The full traceback:
Traceback (most recent call last):
File "test.py", line 9, in <module>
parsed.select("head").render()
File "/usr/lib/pymodules/python2.6/genshi/core.py", line 183, in render
return encode(generator, method=method, encoding=encoding, out=out)
File "/usr/lib/pymodules/python2.6/genshi/output.py", line 57, in encode
return _encode(''.join(list(iterator)))
File "/usr/lib/pymodules/python2.6/genshi/output.py", line 223, in
__call__
for kind, data, pos in stream:
File "/usr/lib/pymodules/python2.6/genshi/output.py", line 670, in
__call__
for kind, data, pos in stream:
File "/usr/lib/pymodules/python2.6/genshi/output.py", line 771, in
__call__
for kind, data, pos in chain(stream, [(None, None, None)]):
File "/usr/lib/pymodules/python2.6/genshi/output.py", line 586, in
__call__
for ev in stream:
File "/usr/lib/pymodules/python2.6/genshi/core.py", line 288, in _ensure
for event in stream:
File "/usr/lib/pymodules/python2.6/genshi/path.py", line 581, in _generate
for event in stream:
File "/usr/lib/pymodules/python2.6/genshi/core.py", line 288, in _ensure
for event in stream:
File "/usr/lib/pymodules/python2.6/genshi/input.py", line 432, in
_coalesce
for kind, data, pos in chain(stream, [(None, None, None)]):
File "/usr/lib/pymodules/python2.6/genshi/input.py", line 327, in
_generate
self.feed(data)
File "/usr/lib/python2.6/HTMLParser.py", line 108, in feed
self.goahead(0)
File "/usr/lib/python2.6/HTMLParser.py", line 148, in goahead
k = self.parse_starttag(i)
File "/usr/lib/python2.6/HTMLParser.py", line 252, in parse_starttag
attrvalue = self.unescape(attrvalue)
File "/usr/lib/python2.6/HTMLParser.py", line 390, in unescape
return re.sub(r"&(#?[xX]?(?:[0-9a-fA-F]+|\w{1,8}));", replaceEntities,
s)
File "/usr/lib/python2.6/re.py", line 151, in sub
return _compile(pattern, 0).sub(repl, string, count)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 9:
ordinal not in range(128)
What this error is about?
puzzled about what does it want.
import genshi
iURL = "http://bugs.farmanager.com/view.php?id=1736"
import urllib2
mbt_file = urllib2.urlopen(iURL)
mbt_genshi = genshi.input.HTMLParser(mbt_file)
parsed = mbt_genshi.parse()
parsed.select("head").render()
The full traceback:
Traceback (most recent call last):
File "test.py", line 9, in <module>
parsed.select("head").render()
File "/usr/lib/pymodules/python2.6/genshi/core.py", line 183, in render
return encode(generator, method=method, encoding=encoding, out=out)
File "/usr/lib/pymodules/python2.6/genshi/output.py", line 57, in encode
return _encode(''.join(list(iterator)))
File "/usr/lib/pymodules/python2.6/genshi/output.py", line 223, in
__call__
for kind, data, pos in stream:
File "/usr/lib/pymodules/python2.6/genshi/output.py", line 670, in
__call__
for kind, data, pos in stream:
File "/usr/lib/pymodules/python2.6/genshi/output.py", line 771, in
__call__
for kind, data, pos in chain(stream, [(None, None, None)]):
File "/usr/lib/pymodules/python2.6/genshi/output.py", line 586, in
__call__
for ev in stream:
File "/usr/lib/pymodules/python2.6/genshi/core.py", line 288, in _ensure
for event in stream:
File "/usr/lib/pymodules/python2.6/genshi/path.py", line 581, in _generate
for event in stream:
File "/usr/lib/pymodules/python2.6/genshi/core.py", line 288, in _ensure
for event in stream:
File "/usr/lib/pymodules/python2.6/genshi/input.py", line 432, in
_coalesce
for kind, data, pos in chain(stream, [(None, None, None)]):
File "/usr/lib/pymodules/python2.6/genshi/input.py", line 327, in
_generate
self.feed(data)
File "/usr/lib/python2.6/HTMLParser.py", line 108, in feed
self.goahead(0)
File "/usr/lib/python2.6/HTMLParser.py", line 148, in goahead
k = self.parse_starttag(i)
File "/usr/lib/python2.6/HTMLParser.py", line 252, in parse_starttag
attrvalue = self.unescape(attrvalue)
File "/usr/lib/python2.6/HTMLParser.py", line 390, in unescape
return re.sub(r"&(#?[xX]?(?:[0-9a-fA-F]+|\w{1,8}));", replaceEntities,
s)
File "/usr/lib/python2.6/re.py", line 151, in sub
return _compile(pattern, 0).sub(repl, string, count)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 9:
ordinal not in range(128)
What this error is about?
--
You received this message because you are subscribed to the Google Groups "Genshi" group.
To view this discussion on the web visit https://groups.google.com/d/msg/genshi/-/KQ02wqbLtGMJ.
To post to this group, send email to ***@googlegroups.com.
To unsubscribe from this group, send email to genshi+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/genshi?hl=en.
You received this message because you are subscribed to the Google Groups "Genshi" group.
To view this discussion on the web visit https://groups.google.com/d/msg/genshi/-/KQ02wqbLtGMJ.
To post to this group, send email to ***@googlegroups.com.
To unsubscribe from this group, send email to genshi+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/genshi?hl=en.