(exc)
| 226 | |
| 227 | def test_callbacks(self): |
| 228 | def handler1(exc): |
| 229 | r = range(exc.start, exc.end) |
| 230 | if isinstance(exc, UnicodeEncodeError): |
| 231 | l = ["<%d>" % ord(exc.object[pos]) for pos in r] |
| 232 | elif isinstance(exc, UnicodeDecodeError): |
| 233 | l = ["<%d>" % exc.object[pos] for pos in r] |
| 234 | else: |
| 235 | raise TypeError("don't know how to handle %r" % exc) |
| 236 | return ("[%s]" % "".join(l), exc.end) |
| 237 | |
| 238 | codecs.register_error("test.handler1", handler1) |
| 239 |
nothing calls this directly
no test coverage detected