Author: duncan
Date: Mon Dec 18 23:09:39 2006
New Revision: 8741
Modified:
branches/rel-1/freevo/src/util/misc.py
Log:
Fixes for BeautifulSoup not processing entities
Modified: branches/rel-1/freevo/src/util/misc.py
==============================================================================
--- branches/rel-1/freevo/src/util/misc.py (original)
+++ branches/rel-1/freevo/src/util/misc.py Mon Dec 18 23:09:39 2006
@@ -373,7 +373,10 @@
semicolon = string.find(";", amp) # find ; as end of entity
if string[amp + 1] == "#": # numerical entity like "'"
entity = string[amp:semicolon+1]
- replacement = Unicode(unichr(int(entity[2:-1])))
+ try:
+ replacement = Unicode(unichr(int(entity[2:-1])))
+ except UnicodeError:
+ replacement = unichr(int(entity[2:-1]))
else:
entity = string[amp:semicolon + 1]
if semicolon - amp > 7:
@@ -383,7 +386,10 @@
replacement = e[entity[1:-1]]
except KeyError:
continue
- string = string.replace(entity, replacement.decode("latin-1"))
+ try:
+ string = string.replace(entity, replacement.decode("latin-1"))
+ except UnicodeError:
+ string = string.replace(entity, replacement)
return string
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog