Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c4fec93

Browse files
committed
Cleanup xmlrpc: remove obsolete comments, unused imports. Add test for bytes marshalling.
1 parent 3fa29f7 commit c4fec93

3 files changed

Lines changed: 11 additions & 21 deletions

File tree

Lib/test/test_xmlrpc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ def test_get_host_info(self):
140140
('host.tld',
141141
[('Authorization', 'Basic dXNlcg==')], {}))
142142

143+
def test_dump_bytes(self):
144+
self.assertRaises(TypeError, xmlrpclib.dumps, (b"my dog has fleas",))
145+
143146
def test_ssl_presence(self):
144147
try:
145148
import ssl
@@ -177,7 +180,7 @@ def test_dump_fault(self):
177180
self.assertRaises(xmlrpclib.Fault, xmlrpclib.loads, s)
178181

179182
def test_dotted_attribute(self):
180-
# this will raise AttirebuteError because code don't want us to use
183+
# this will raise AttributeError because code don't want us to use
181184
# private methods
182185
self.assertRaises(AttributeError,
183186
xmlrpc.server.resolve_dotted_attribute, str, '__add')

Lib/xmlrpc/client.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,6 @@
8585
# OF THIS SOFTWARE.
8686
# --------------------------------------------------------------------
8787

88-
#
89-
# things to look into some day:
90-
91-
# TODO: sort out True/False/boolean issues for Python 2.3
92-
9388
"""
9489
An XML-RPC client interface for Python.
9590
@@ -120,8 +115,7 @@
120115
121116
Exported constants:
122117
123-
True
124-
False
118+
(none)
125119
126120
Exported functions:
127121
@@ -133,7 +127,8 @@
133127
name (None if not present).
134128
"""
135129

136-
import re, time, operator
130+
import base64
131+
import time
137132
import http.client
138133
from xml.parsers import expat
139134
import socket
@@ -230,7 +225,7 @@ class ResponseError(Error):
230225
##
231226
# Indicates an XML-RPC fault response package. This exception is
232227
# raised by the unmarshalling layer, if the XML-RPC response contains
233-
# a fault string. This exception can also used as a class, to
228+
# a fault string. This exception can also be used as a class, to
234229
# generate a fault XML-RPC message.
235230
#
236231
# @param faultCode The XML-RPC fault code.
@@ -243,10 +238,7 @@ def __init__(self, faultCode, faultString, **extra):
243238
self.faultCode = faultCode
244239
self.faultString = faultString
245240
def __repr__(self):
246-
return (
247-
"<Fault %s: %s>" %
248-
(self.faultCode, repr(self.faultString))
249-
)
241+
return "<Fault %s: %r>" % (self.faultCode, self.faultString)
250242

251243
# --------------------------------------------------------------------
252244
# Special values
@@ -352,7 +344,7 @@ def __str__(self):
352344
return self.value
353345

354346
def __repr__(self):
355-
return "<DateTime %s at %x>" % (repr(self.value), id(self))
347+
return "<DateTime %r at %x>" % (self.value, id(self))
356348

357349
def decode(self, data):
358350
self.value = str(data).strip()
@@ -378,9 +370,6 @@ def _datetime_type(data):
378370
#
379371
# @param data An 8-bit string containing arbitrary data.
380372

381-
import base64
382-
import io
383-
384373
class Binary:
385374
"""Wrapper for binary data."""
386375

@@ -1198,7 +1187,6 @@ def get_host_info(self, host):
11981187
auth, host = urllib.parse.splituser(host)
11991188

12001189
if auth:
1201-
import base64
12021190
auth = urllib.parse.unquote_to_bytes(auth)
12031191
auth = base64.encodebytes(auth).decode("utf-8")
12041192
auth = "".join(auth.split()) # get rid of whitespace

Lib/xmlrpc/server.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,6 @@ def system_methodHelp(self, method_name):
329329
if method is None:
330330
return ""
331331
else:
332-
import pydoc
333332
return pydoc.getdoc(method)
334333

335334
def system_multicall(self, call_list):
@@ -560,7 +559,7 @@ class SimpleXMLRPCServer(socketserver.TCPServer,
560559
Simple XML-RPC server that allows functions and a single instance
561560
to be installed to handle requests. The default implementation
562561
attempts to dispatch XML-RPC calls to the functions or instance
563-
installed in the server. Override the _dispatch method inhereted
562+
installed in the server. Override the _dispatch method inherited
564563
from SimpleXMLRPCDispatcher to change this behavior.
565564
"""
566565

0 commit comments

Comments
 (0)