diff options
Diffstat (limited to 'Lib/xml/etree')
-rw-r--r-- | Lib/xml/etree/ElementTree.py | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py index aed69bb..19bb747 100644 --- a/Lib/xml/etree/ElementTree.py +++ b/Lib/xml/etree/ElementTree.py @@ -109,7 +109,7 @@ __all__ = [ # structure, and convert it from and to XML. ## -import string, sys, re +import sys, re from . import ElementPath @@ -762,7 +762,7 @@ def _encode_entity(text, pattern=_escape): if text is None: text = "&#%d;" % ord(char) append(text) - return string.join(out, "") + return "".join(out) try: return _encode(pattern.sub(escape_entities, text), "ascii") except TypeError: @@ -772,7 +772,7 @@ def _encode_entity(text, pattern=_escape): # the following functions assume an ascii-compatible encoding # (or "utf-16") -def _escape_cdata(text, encoding=None, replace=string.replace): +def _escape_cdata(text, encoding=None): # escape character data try: if encoding: @@ -780,14 +780,14 @@ def _escape_cdata(text, encoding=None, replace=string.replace): text = _encode(text, encoding) except UnicodeError: return _encode_entity(text) - text = replace(text, "&", "&") - text = replace(text, "<", "<") - text = replace(text, ">", ">") + text = text.replace("&", "&") + text = text.replace("<", "<") + text = text.replace(">", ">") return text except (TypeError, AttributeError): _raise_serialization_error(text) -def _escape_attrib(text, encoding=None, replace=string.replace): +def _escape_attrib(text, encoding=None): # escape attribute value try: if encoding: @@ -795,11 +795,11 @@ def _escape_attrib(text, encoding=None, replace=string.replace): text = _encode(text, encoding) except UnicodeError: return _encode_entity(text) - text = replace(text, "&", "&") - text = replace(text, "'", "'") # FIXME: overkill - text = replace(text, "\"", """) - text = replace(text, "<", "<") - text = replace(text, ">", ">") + text = text.replace("&", "&") + text = text.replace("'", "'") # FIXME: overkill + text = text.replace("\"", """) + text = text.replace("<", "<") + text = text.replace(">", ">") return text except (TypeError, AttributeError): _raise_serialization_error(text) @@ -809,7 +809,7 @@ def fixtag(tag, namespaces): # tag and namespace declaration, if any if isinstance(tag, QName): tag = tag.text - namespace_uri, tag = string.split(tag[1:], "}", 1) + namespace_uri, tag = tag[1:].split("}", 1) prefix = namespaces.get(namespace_uri) if prefix is None: prefix = _namespace_map.get(namespace_uri) @@ -982,7 +982,7 @@ def tostring(element, encoding=None): file = dummy() file.write = data.append ElementTree(element).write(file, encoding) - return string.join(data, "") + return "".join(data) ## # Generic element structure builder. This builder converts a sequence @@ -1021,7 +1021,7 @@ class TreeBuilder: def _flush(self): if self._data: if self._last is not None: - text = string.join(self._data, "") + text = "".join(self._data) if self._tail: assert self._last.tail is None, "internal error (tail)" self._last.tail = text @@ -1182,7 +1182,7 @@ class XMLTreeBuilder: if prefix == ">": self._doctype = None return - text = string.strip(text) + text = text.strip() if not text: return self._doctype.append(text) |