Skip to content

Commit ff11334

Browse files
committed
Remove the SlowParser class because it depended on the xmllib module
which was removed. Use string methods rather than the string module.
1 parent 53855c6 commit ff11334

1 file changed

Lines changed: 11 additions & 30 deletions

File tree

Lib/xmlrpclib.py

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
name (None if not present).
137137
"""
138138

139-
import re, string, time, operator
139+
import re, time, operator
140140

141141
from types import *
142142

@@ -164,10 +164,10 @@ def _decode(data, encoding, is8bit=re.compile("[\x80-\xff]").search):
164164
data = unicode(data, encoding)
165165
return data
166166

167-
def escape(s, replace=string.replace):
168-
s = replace(s, "&", "&")
169-
s = replace(s, "<", "&lt;")
170-
return replace(s, ">", "&gt;",)
167+
def escape(s):
168+
s = s.replace("&", "&amp;")
169+
s = s.replace("<", "&lt;")
170+
return s.replace(">", "&gt;",)
171171

172172
if unicode:
173173
def _stringify(string):
@@ -346,8 +346,7 @@ def __repr__(self):
346346
return "<DateTime %s at %x>" % (repr(self.value), id(self))
347347

348348
def decode(self, data):
349-
data = str(data)
350-
self.value = string.strip(data)
349+
self.value = str(data).strip()
351350

352351
def encode(self, out):
353352
out.write("<value><dateTime.iso8601>")
@@ -513,24 +512,6 @@ def close(self):
513512
self._parser.Parse("", 1) # end of data
514513
del self._target, self._parser # get rid of circular references
515514

516-
class SlowParser:
517-
"""Default XML parser (based on xmllib.XMLParser)."""
518-
# this is about 10 times slower than sgmlop, on roundtrip
519-
# testing.
520-
def __init__(self, target):
521-
import xmllib # lazy subclassing (!)
522-
if xmllib.XMLParser not in SlowParser.__bases__:
523-
SlowParser.__bases__ = (xmllib.XMLParser,)
524-
self.handle_xml = target.xml
525-
self.unknown_starttag = target.start
526-
self.handle_data = target.data
527-
self.handle_cdata = target.data
528-
self.unknown_endtag = target.end
529-
try:
530-
xmllib.XMLParser.__init__(self, accept_utf8=1)
531-
except TypeError:
532-
xmllib.XMLParser.__init__(self) # pre-2.0
533-
534515
# --------------------------------------------------------------------
535516
# XML-RPC marshalling and unmarshalling code
536517

@@ -586,7 +567,7 @@ def dumps(self, values):
586567
dump(v, write)
587568
write("</param>\n")
588569
write("</params>\n")
589-
result = string.join(out, "")
570+
result = "".join(out)
590571
return result
591572

592573
def __dump(self, value, write):
@@ -786,14 +767,14 @@ def start(self, tag, attrs):
786767
def data(self, text):
787768
self._data.append(text)
788769

789-
def end(self, tag, join=string.join):
770+
def end(self, tag):
790771
# call the appropriate end tag handler
791772
try:
792773
f = self.dispatch[tag]
793774
except KeyError:
794775
pass # unknown tag ?
795776
else:
796-
return f(self, join(self._data, ""))
777+
return f(self, "".join(self._data))
797778

798779
#
799780
# accelerator support
@@ -1085,7 +1066,7 @@ def dumps(params, methodname=None, methodresponse=None, encoding=None,
10851066
)
10861067
else:
10871068
return data # return as is
1088-
return string.join(data, "")
1069+
return "".join(data)
10891070

10901071
##
10911072
# Convert an XML-RPC packet to a Python object. If the XML-RPC packet
@@ -1210,7 +1191,7 @@ def get_host_info(self, host):
12101191
if auth:
12111192
import base64
12121193
auth = base64.encodestring(urllib.unquote(auth))
1213-
auth = string.join(string.split(auth), "") # get rid of whitespace
1194+
auth = "".join(auth.split()) # get rid of whitespace
12141195
extra_headers = [
12151196
("Authorization", "Basic " + auth)
12161197
]

0 commit comments

Comments
 (0)