(exc)
| 98 | # characters, if one is available. |
| 99 | |
| 100 | def xmlcharnamereplace(exc): |
| 101 | if not isinstance(exc, UnicodeEncodeError): |
| 102 | raise TypeError("don't know how to handle %r" % exc) |
| 103 | l = [] |
| 104 | for c in exc.object[exc.start:exc.end]: |
| 105 | try: |
| 106 | l.append("&%s;" % html.entities.codepoint2name[ord(c)]) |
| 107 | except KeyError: |
| 108 | l.append("&#%d;" % ord(c)) |
| 109 | return ("".join(l), exc.end) |
| 110 | |
| 111 | codecs.register_error( |
| 112 | "test.xmlcharnamereplace", xmlcharnamereplace) |
nothing calls this directly
no test coverage detected