MCPcopy Index your code
hub / github.com/RustPython/RustPython / xmlcharnamereplace

Method xmlcharnamereplace

Lib/test/test_codeccallbacks.py:100–109  ·  view source on GitHub ↗
(exc)

Source from the content-addressed store, hash-verified

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)

Callers

nothing calls this directly

Calls 4

isinstanceFunction · 0.85
ordFunction · 0.85
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected