MCPcopy Index your code
hub / github.com/python/cpython / _escape_cdata

Function _escape_cdata

Lib/xml/etree/ElementTree.py:1018–1032  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

1016 )
1017
1018def _escape_cdata(text):
1019 # escape character data
1020 try:
1021 # it's worth avoiding do-nothing calls for strings that are
1022 # shorter than 500 characters, or so. assume that's, by far,
1023 # the most common case in most applications.
1024 if "&" in text:
1025 text = text.replace("&", "&")
1026 if "<" in text:
1027 text = text.replace("<", "&lt;")
1028 if ">" in text:
1029 text = text.replace(">", "&gt;")
1030 return text
1031 except (TypeError, AttributeError):
1032 _raise_serialization_error(text)
1033
1034def _escape_attrib(text):
1035 # escape attribute value

Callers 2

_serialize_xmlFunction · 0.85
_serialize_htmlFunction · 0.85

Calls 2

replaceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…