ValueError

20 views
Skip to first unread message

lancess

unread,
May 12, 2009, 10:15:48 AM5/12/09
to beautifulsoup
Hi,

beautifulsoup 3.1.0.1 is crashing on this javascript:
sortrevind.innerHTML = stIsIE ? '&nbsp<font face="webdings">5</
font>' : '&nbsp;&#x25B4;';

Can you help?

[python] File "BeautifulSoup.py", line 1047, in handle_charref
[python] data = unichr(int(ref))
[python] ValueError: invalid literal for int() with base 10:
'x25B4'

Thanks

Marcos Dione

unread,
May 16, 2009, 2:13:40 PM5/16/09
to beautifulsoup
try this patch:

--- cut here ---
--- BeautifulSoup.py.orig 2009-01-06 19:10:49.000000000 -0200
+++ BeautifulSoup.py 2009-05-16 15:05:40.000000000 -0300
@@ -1044,7 +1044,10 @@
def handle_charref(self, ref):
"Handle character references as data."
if self.soup.convertEntities:
- data = unichr(int(ref))
+ if ref[0] in ('x', 'X'):
+ data = unichr(int('0'+ref,16))
+ else:
+ data = unichr(int(ref))
else:
data = '&#%s;' % ref
self.handle_data(data)
--- cut here ---

save it to BS.diff, go to the dir where BeautifulSoup.py is, patch -p0
< BS.diff.
Reply all
Reply to author
Forward
0 new messages