mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Fix xmlrpc unittest. While it now passes on Linux, it still fails
on FreeBSD due to the difference of socket blocking mode inheritance.
This commit is contained in:
parent
faa54a3929
commit
9604286ee1
2 changed files with 7 additions and 25 deletions
|
@ -141,19 +141,6 @@ def list_public_methods(obj):
|
||||||
if not member.startswith('_') and
|
if not member.startswith('_') and
|
||||||
hasattr(getattr(obj, member), '__call__')]
|
hasattr(getattr(obj, member), '__call__')]
|
||||||
|
|
||||||
def remove_duplicates(lst):
|
|
||||||
"""remove_duplicates([2,2,2,1,3,3]) => [3,1,2]
|
|
||||||
|
|
||||||
Returns a copy of a list without duplicates. Every list
|
|
||||||
item must be hashable and the order of the items in the
|
|
||||||
resulting list is not defined.
|
|
||||||
"""
|
|
||||||
u = {}
|
|
||||||
for x in lst:
|
|
||||||
u[x] = 1
|
|
||||||
|
|
||||||
return u.keys()
|
|
||||||
|
|
||||||
class SimpleXMLRPCDispatcher:
|
class SimpleXMLRPCDispatcher:
|
||||||
"""Mix-in class that dispatches XML-RPC requests.
|
"""Mix-in class that dispatches XML-RPC requests.
|
||||||
|
|
||||||
|
@ -276,23 +263,18 @@ class SimpleXMLRPCDispatcher:
|
||||||
|
|
||||||
Returns a list of the methods supported by the server."""
|
Returns a list of the methods supported by the server."""
|
||||||
|
|
||||||
methods = self.funcs.keys()
|
methods = set(self.funcs.keys())
|
||||||
if self.instance is not None:
|
if self.instance is not None:
|
||||||
# Instance can implement _listMethod to return a list of
|
# Instance can implement _listMethod to return a list of
|
||||||
# methods
|
# methods
|
||||||
if hasattr(self.instance, '_listMethods'):
|
if hasattr(self.instance, '_listMethods'):
|
||||||
methods = remove_duplicates(
|
methods |= set(self.instance._listMethods())
|
||||||
methods + self.instance._listMethods()
|
|
||||||
)
|
|
||||||
# if the instance has a _dispatch method then we
|
# if the instance has a _dispatch method then we
|
||||||
# don't have enough information to provide a list
|
# don't have enough information to provide a list
|
||||||
# of methods
|
# of methods
|
||||||
elif not hasattr(self.instance, '_dispatch'):
|
elif not hasattr(self.instance, '_dispatch'):
|
||||||
methods = remove_duplicates(
|
methods |= set(list_public_methods(self.instance))
|
||||||
methods + list_public_methods(self.instance)
|
return sorted(methods)
|
||||||
)
|
|
||||||
methods.sort()
|
|
||||||
return methods
|
|
||||||
|
|
||||||
def system_methodSignature(self, method_name):
|
def system_methodSignature(self, method_name):
|
||||||
"""system.methodSignature('add') => [double, int, int]
|
"""system.methodSignature('add') => [double, int, int]
|
||||||
|
@ -459,7 +441,7 @@ class SimpleXMLRPCRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
|
||||||
chunk_size = min(size_remaining, max_chunk_size)
|
chunk_size = min(size_remaining, max_chunk_size)
|
||||||
L.append(self.rfile.read(chunk_size))
|
L.append(self.rfile.read(chunk_size))
|
||||||
size_remaining -= len(L[-1])
|
size_remaining -= len(L[-1])
|
||||||
data = ''.join(L)
|
data = b''.join(L)
|
||||||
|
|
||||||
# In previous versions of SimpleXMLRPCServer, _dispatch
|
# In previous versions of SimpleXMLRPCServer, _dispatch
|
||||||
# could be overridden in this class, instead of in
|
# could be overridden in this class, instead of in
|
||||||
|
|
|
@ -1117,8 +1117,8 @@ class Transport:
|
||||||
if resp.status != 200:
|
if resp.status != 200:
|
||||||
raise ProtocolError(
|
raise ProtocolError(
|
||||||
host + handler,
|
host + handler,
|
||||||
errcode, errmsg,
|
resp.status, resp.reason,
|
||||||
headers
|
resp.getheaders()
|
||||||
)
|
)
|
||||||
|
|
||||||
self.verbose = verbose
|
self.verbose = verbose
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue