mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
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
This commit is contained in:
parent
ff11334927
commit
9d72bb452b
69 changed files with 396 additions and 2113 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue