--- /home/poma1006/mpfiles/.eclipse/workspace-code/release26-maint/Lib/HTMLParser.py 2010-12-22 17:27:33.498246013 +0100 +++ /home/poma1006/Desktop/HTMLParser.py 2010-12-22 17:29:08.619496212 +0100 @@ -369,11 +369,14 @@ s = s.groups()[0] if s[0] == "#": s = s[1:] - if s[0] in ['x','X']: - c = int(s[1:], 16) - else: - c = int(s) - return unichr(c) + try: + if s[0] in ['x','X']: + c = int(s[1:], 16) + else: + c = int(s) + return unichr(c) + except ValueError: + return '&#'+s+';' else: # Cannot use name2codepoint directly, because HTMLParser supports apos, # which is not part of HTML 4