Remove functions in string module that are also string methods. Also remove:
* all calls to functions in the string module (except maketrans)
* everything from stropmodule except for maketrans() which is still used
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 @@
# structure, and convert it from and to XML.
##
-import string, sys, re
+import sys, re
from . import ElementPath
@@ -762,7 +762,7 @@
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 @@
# 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 @@
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 @@
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 @@
# 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 @@
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 @@
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 @@
if prefix == ">":
self._doctype = None
return
- text = string.strip(text)
+ text = text.strip()
if not text:
return
self._doctype.append(text)