Skip to content

Commit 9604286

Browse files
committed
Fix xmlrpc unittest. While it now passes on Linux, it still fails
on FreeBSD due to the difference of socket blocking mode inheritance.
1 parent faa54a3 commit 9604286

2 files changed

Lines changed: 7 additions & 25 deletions

File tree

Lib/SimpleXMLRPCServer.py

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -141,19 +141,6 @@ def list_public_methods(obj):
141141
if not member.startswith('_') and
142142
hasattr(getattr(obj, member), '__call__')]
143143

144-
def remove_duplicates(lst):
145-
"""remove_duplicates([2,2,2,1,3,3]) => [3,1,2]
146-
147-
Returns a copy of a list without duplicates. Every list
148-
item must be hashable and the order of the items in the
149-
resulting list is not defined.
150-
"""
151-
u = {}
152-
for x in lst:
153-
u[x] = 1
154-
155-
return u.keys()
156-
157144
class SimpleXMLRPCDispatcher:
158145
"""Mix-in class that dispatches XML-RPC requests.
159146
@@ -276,23 +263,18 @@ def system_listMethods(self):
276263
277264
Returns a list of the methods supported by the server."""
278265

279-
methods = self.funcs.keys()
266+
methods = set(self.funcs.keys())
280267
if self.instance is not None:
281268
# Instance can implement _listMethod to return a list of
282269
# methods
283270
if hasattr(self.instance, '_listMethods'):
284-
methods = remove_duplicates(
285-
methods + self.instance._listMethods()
286-
)
271+
methods |= set(self.instance._listMethods())
287272
# if the instance has a _dispatch method then we
288273
# don't have enough information to provide a list
289274
# of methods
290275
elif not hasattr(self.instance, '_dispatch'):
291-
methods = remove_duplicates(
292-
methods + list_public_methods(self.instance)
293-
)
294-
methods.sort()
295-
return methods
276+
methods |= set(list_public_methods(self.instance))
277+
return sorted(methods)
296278

297279
def system_methodSignature(self, method_name):
298280
"""system.methodSignature('add') => [double, int, int]
@@ -459,7 +441,7 @@ def do_POST(self):
459441
chunk_size = min(size_remaining, max_chunk_size)
460442
L.append(self.rfile.read(chunk_size))
461443
size_remaining -= len(L[-1])
462-
data = ''.join(L)
444+
data = b''.join(L)
463445

464446
# In previous versions of SimpleXMLRPCServer, _dispatch
465447
# could be overridden in this class, instead of in

Lib/xmlrpclib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,8 +1117,8 @@ def request(self, host, handler, request_body, verbose=0):
11171117
if resp.status != 200:
11181118
raise ProtocolError(
11191119
host + handler,
1120-
errcode, errmsg,
1121-
headers
1120+
resp.status, resp.reason,
1121+
resp.getheaders()
11221122
)
11231123

11241124
self.verbose = verbose

0 commit comments

Comments
 (0)